0

I'd like to load a url in a UIWebView. Then when a user clicks a button on the HTML page, I use the shouldStartLoadWithRequest method on the UIWebView to intercept the click and tell the UIWebView to load the new url but re-animate the same instance of the UIWebVIew like it was a new UIWebView being pushed on the stack. Also, I'd like to hook up the back button functionality to basically do the reverse of this.

Is this possible?

sathiamoorthy
  • 1,470
  • 1
  • 13
  • 23
a2345sooted
  • 519
  • 5
  • 18
  • Yep. For anyone looking to the same: http://stackoverflow.com/questions/17636280/make-a-flip-animation-or-something-similar-when-i-reload-the-content-of-my-uiw – a2345sooted Feb 03 '14 at 09:32

1 Answers1

0

I think, that you have no options to use only one UIWebView in this case. In your example they use flip animation, but you want push and your webView have to use more space for this.

You can just use array of webViews, handle webViewDidFinishLoad: and just move them to right.

Also you can just use flip animation.

About hooking up the back button: You have to implement back button by yourself. To implement back button you have to use goBack method of webView.

EDIT: I just understand that you use navigationController to push and pop you webViews. I think that it is a bad practice because users would be confused. We have to use push and pop with navigation controller to navigate between different logical screens. But in that case we just update our content.

I think that it can break HIG. It will be better if you implement you animation less "push/pop navigation". And now I think it will be better to use another type of animation. It's harder but less complicated for user.

But in case you want to use navigationController you can just clean part of navigation stack in didReceiveMemoryWarning method.

And about back button of navigationController. Actually, it's a hard question and answers aren't straightforward: back button callback in navigationController in iOS and Setting action for back button in navigation controller

Community
  • 1
  • 1
kaspartus
  • 1,325
  • 15
  • 32
  • I have the functionality and animations working great by just pushing a new webView everytime. But I'm trying to be aware of my memory usage here. Since the new HTML loaded by the click could contain links to do the same thing over and over, I'm worried about having a bunch of webViews open. Although, I'm not really seeing a big jump in memory usage when pushing a new webview. Do you think pushing new views is something I should try to avoid here? – a2345sooted Feb 03 '14 at 09:53
  • Yes, it isn't a good idea to create new webViews without control. I think that you can cap number of webViews and store them in NSMutableArray for example. Also you can just handle didReceiveMemoryWarning in your viewController and clear all webViews after last 5 for example. – kaspartus Feb 03 '14 at 10:04
  • I like your second recommendation. Seems like it would be easy to implement and not worry about taking the long way around unless necessary. – a2345sooted Feb 03 '14 at 10:06