IOS button on webpage with uiwebview

For the current project, I am introducing a mobile site into the iOS application. I used goback () and goforward () functions with UIWebView. But how can I make a custom function that onClick (or onTouch, which is the correct term ever) Sends a UIWebView back to the loaded page? Any help would be greatly appreciated as I have not been able to find anything on the Internet so far.

+2
source share
1 answer

Add something like an implementation file:

- (IBAction)loadPage:(id)sender; { NSURL *url = [NSURL URLWithString:@"http://www.stackoverflow.com/"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [webView loadRequest:request]; } 

And add this to the header file (each line in the corresponding position):

 - (IBAction)loadPage:(id)sender; IBOutlet UIWebView *webView; 

Then bind the loadPage button in the interface builder,
and bind webView to UIWebView.

Reply to comment:

I created this sample project, hope this helps:
- http://dd5.org/static/iPhone_Browser_Sample.zip

Button Binding:

Right click and drag to the class where you added the code above.
Release the button. A small dark gray panel will now appear.
Then click on the loadPage: element in this panel.
If the code was added correctly, the entry should appear there.

+4
source

All Articles