Im currently working on an app which lists a set of objects in a tableview, when the user clicks on one of the objects it opens a UIWebview which should display a paragraph of text (which is stored in html format in core data), I would also like the user to be able to scroll up and down in the web view to see the previous/next paragraphs.
So far I have this:
NSMutableArray *paras = [sharedHelper dataParagraphs];
NSMutableData *htmlData = [[NSMutableData alloc] init];
for (DataParagraph *dp in paras) {
[htmlData appendData:[dp Body]];
}
[web loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:nil];
Which basically gets all the paragraphs and displays them in the web view. So, my question is if i load just the paragraph for the object that has been clicked, is there anyway i can then load the previous and next paragraph dynamically without refreshing the web view? I was thinking about displaying the paragraphs inside a UITableView but I’m not sure if you can display html code in a UITableViewCell?
Any help is much appreciated.
Create an array of objects in your WebView VC and declare that as a property, also declare an NSInteger property on the WebView VC as well.
Then build that same array of all the html objects in your CD entity and pass that along with the selectedindexpath.row to the WebView VC.
When the WebView loads, load up the html object in the array corresponding to the indexpath.row property.
Use gesture recognizers or scroll position to load previous, next indexes in the html object array.