-3

I need the back button to make the browser go back, instead of navigate through the different app views.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
fewaf
  • 145
  • 13

1 Answers1

2

I assume the "web browser" is a UIWebView? If so, the -goBack method will go back to the prior web page.

You shouldn't use the navigation bar to do this, as the navigation bar is primarily intended for navigating the views/screens of the app. Instead, create a toolbar, put a "back button" in the toolbar (perhaps a left-pointing arrow image, as that's fairly common for web browser "back"), and hook this button to the -goBack method.

You may not be able to hook the -goBack method directly to your button, as it's strictly not an IBAction. But that's easy enough to work around:

- (IBAction)doGoBack:(id)sender {
    [self.webview goBack];
}
hsoi
  • 2,764
  • 3
  • 19
  • 20
  • Great, thanks. For some reason looking at the tutorials, they all had all this code to copy into the files along with hooking the button to goBack. That code kept giving me errors.But it works now. – fewaf Mar 16 '14 at 18:40