Lior Z
Lior Z

Reputation: 668

Simple iOS app to show my site in UIWebView *with* back / refresh controllers

Looking all over for a simple Xcode project that will load my web site in a UIWebView that has the default Safari controllers for back / refresh the page - but can't seem to find one.

All I could find was a great template project, but it didn't have the controllers. And since I am very new to iOS development, I can't figure out how to add the controllers.

Can anyone help me out with complete source for something like that?

Thanks

Upvotes: 0

Views: 168

Answers (1)

JiaYow
JiaYow

Reputation: 5227

  • Add a navigationbar above or a toolbar under the webview
  • Put two barbuttonitems/buttons into the bar, one for back and one for forward. Of course you can also use the segmented control
  • Set the webview's delegate to the view controller of the view
  • In the TouchDown-actions of the buttons, call webView's goBack: or goForward: methods

For the method references, see here: https://developer.apple.com/library/ios/documentation/uikit/reference/UIWebView_Class/Reference/Reference.html#//apple_ref/occ/instm/UIWebView/goBack

The same can of course be done with reload (the method is called refresh), and this SO even shows an example of how to do it: Refresh a UIWebView

Upvotes: 1

Related Questions