views:

35

answers:

1

... with a button outside of the uiwebview? please see screenshot attached.

the thing is, that I have a local html site in the webview, that goes to further local web sites. I want the user to be able to get back to the "home page" of the local website by clicking on the "home" button on the top, which is not part of the uiwebview.

(my xcode status is beginner.)

thanks for help.

A: 

You can refresh the webview by calling loadRequest method under the UIWebView class.

[webView loadRequest:[NSURLRequest requestWithURL:theURL]];

You have to pass your url in "thURL". So, you will get the refreshed page.

Tech Guru
thanks. just to understand: first I make an IB Action in the .h: - (IBAction)refresh:(id)sender; theURL is my local url like test.html?
andy
this does not work in .m:- (IBAction)refresh:(id)sender { [webView loadRequest:[NSURLRequest requestWithURL:html.html]]; }
andy
I have this in my viewcontroller under viewDidLoad: [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"html" ofType:@"html"] isDirectory:NO]]];
andy
I have in my view controller this, but it doesn't work: - (IBAction)refresh:(id)sender { [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"html" ofType:@"html"] isDirectory:NO]]]; }
andy
Have you set the delegate for the webview? If not then please try to set the delegate first and try again one more time.
Tech Guru
yeah! thanks, now it works perfect!
andy
You are most welcomed. If you need any help for future, you can ask me anytime. I will try my best to help you out there..
Tech Guru