0

I'm looking at how to make a very simple browser in my app. Only need reload, back, forward, etc.

Does anyone have any simple code they can add here?

I have a tableviewcell that when clicked will launch this view.

Cœur
  • 37,241
  • 25
  • 195
  • 267

2 Answers2

1

Add a UIWebView.

You can use

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]]` 

to open a website, -reload to reload, – goBack and -goForward to go back or forward.

fabian789
  • 8,348
  • 4
  • 45
  • 91
  • Would I first create a UIWebView in IB? Then I can push this view in didSelectRowAtIndexPath? –  Apr 22 '11 at 07:42
  • You would create a new `UIViewController` subclass with an XIB, open the XIB in IB and then add a `UIWebView` to the view of the `UIViewController` by dragging it from the Library. – fabian789 Apr 22 '11 at 07:49
  • Ok, I got it all setup, I have the view loading google.com. How would I add buttons for reload, forward, back, etc. –  Apr 22 '11 at 08:03
  • Just add some buttons to your `UIViewController` and add some IBActions. In these methods, you call the methods I mentioned. – fabian789 Apr 22 '11 at 08:07
  • Ok ill try that. Do you know how to hid the tab bar, and replace it with a toolbar? –  Apr 22 '11 at 08:09
  • You might want to look [here](http://stackoverflow.com/questions/815690/hide-uitabbar). To show the toolbar, do `yourVC.navigationController.toolbarHidden = NO`, where `yourVC` is the `UIViewController` you created. The best place to do this is probably `-viewWillAppear`. – fabian789 Apr 22 '11 at 08:13
0

Check out the UIWebView API, which is basically a WebKit rendering widget - the one that also powers iPhone's browser app.

plaes
  • 31,788
  • 11
  • 91
  • 89