views:

75

answers:

1

Hello fellow programmers,

What im tyring to create is an application the utilizes book features like when the user drags a touch or just touches the right screen the page turns, the book im trying to create has atleats 300 pages. What i need is a starting point on how to access the text data and display it on a view. When the user changes the page the next set of text is accesed and displayed. How would i be able to model a book with so many pages? any help is appreciated PS: ive tried looking for simple tutorials but no luck

A: 

If you have your text data in a .txt file then you can extract it from there first of all. This post gives info on how you can do that.

Then every time you flick the page just load in an appropriate substring from the entire text. This would be best in an uneditable UITextView. It could look something like this:

int maxCharPerPage = 200;
int lastCharPreviousPage = 1000;

NSRange thisPageRange = NSMakeRange(lastCharPreviousPage+1, lastCharPreviousPage+1+maxCharPerPage);
NSString *thisPageText = [entireBookText substringWithRange:thisPageRange];

textView.text = thisPageText;

Or you could use a UILabel on top of a view but this approach isn't really what UILabel is designed for.

imnk