0

i have a html file that contains some data,since i display this in a webview the user has to scroll down to view the information,what i want to know is whether i can provide a page curl animation to view the contents of the html so that it becomes easier for the user to read the information by swiping across pages,

should i use pageviewcontroller? or are there any other libraries that let me have the page curl effect on a custom(webview)? how do i proceed? is it possible to show some amount of html information on one page and then user turns to the next page? how do i achieve that,its a single html file

BoredToDeath
  • 431
  • 2
  • 7
  • 21

1 Answers1

0

If you want that sort of paging, then maybe you could try the leaves library https://github.com/brow/leaves You can use it to page through various UIWebView's As you can see in the leaves sample you have to render the page in the renderPageAtIndex. You can then use something like:

- (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx {

CGSize screensize = CGSizeMake(320,480);

UIGraphicsBeginImageContext(screensize); CGContextRef context = UIGraphicsGetCurrentContext(); CGFloat scalingFactor = screensize.width/webView.frame.size.width; CGContextScaleCTM(context, scalingFactor,scalingFactor);

[webView.layer renderInContext: ctx]; }

You do have to load the webview first.

Edwin Vermeer
  • 13,017
  • 2
  • 34
  • 58
  • As you can see in the leaves sample you have to render the page in the renderPageAtIndex method. I included a sample in my awnser above – Edwin Vermeer Feb 01 '13 at 14:32
  • i tried what you asked me,a little more guidance and i will be very grateful,this is what i have tried http://pastebin.com/YDG0SFSM please let me know if its correct or not,thanks – BoredToDeath Feb 01 '13 at 17:06
  • What's the problem? Are you getting blank pages? That's probably because the webpage is not ready. You are doing the renderInContext right after loadRequest. The webpage will not be ready. I think you need to render the page before the renderPageAtIndex. If so, then you probably need multiple webviews. – Edwin Vermeer Feb 02 '13 at 10:04
  • yes i am getting blank pages,i am not sure i can understand what you are trying to tell me,i understood that the webpage will not be ready,i am not understanding what multiple webviews are you mentioning,can you just help me with that thanks.. – BoredToDeath Feb 02 '13 at 15:21
  • 1
    what i mean is that you need to preload multiple webviews zo that on the renderPageAtIndex the webview is already loaded. The webviews must also be on screen (but can be hidden behind other controls) otherwise the webview will not be rendered. I think the most flexible way is to preload both the previous and next page (and on startup the current page) – Edwin Vermeer Feb 02 '13 at 16:03
  • so if i am not wrong you are telling to have multiple webviews loaded with request in viewDidLoad correct? then i add the webviews to an NSArray so i can count them,but how do i iterate between these multiple webviews,i am really this close to get it,please help me with that,thanks – BoredToDeath Feb 02 '13 at 16:21
  • I think 2 webvieuws would be enough. In the viewdidload load webView1 with the first page and webView2 with the second page. Also keep track of 2 page indicators. something like: view1page = 1, view2page =2; in the renderPageAtIndex do something like: if(index==view1page)... code for using webview1, do the same for the view2page. At the end of therenderPageAtindex load the page with index-1 in webview1 and load the page with index+1 in the webview2. This will make sure that the previous and next pages are rendered – Edwin Vermeer Feb 02 '13 at 16:43