hi i guess this is pretty simple and hope it will be answered in a easy manner!
how do i change the url of the uiwebview when a button is touched up inside?
meaning to say i will have a single web view and everytime a button is clicked the URL of the webview
changes and a new page is reloaded
thanks
As you suggest, it's very easy:
-(void)buttonPressed:(id)sender {
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://website.com/"]]];
}
This is all very well documented.
Related
Here we are using UIWebview related application.
while clicking on some links, it's automatically connect(go) to the itunes.
but it's cannot get back to the app after clicking a itunes link (with out clicking on Exit).
My Question is, how can come back to the app after clicking a itunes.
Try this one uiwebview delegate method.
-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL* url = [request URL];
if (UIWebViewNavigationTypeLinkClicked == navigationType)
{
[[UIApplication sharedApplication] openURL:url];
return NO;
}
return YES;
}
I usually insert a button next to UIWebView.
Use a new view and insert button in any corner of view and then put your UIWebView, set your uiwebview is not fit to screen so you can push to exit button. When you tap to button than hide your view. ITs usually what i do for such situation, maybe it can help to you
When you click on any link and you now go to at this link of page and if you want to go previous to your application. Generally You can not go Back to your Application because Apple iOS does not provide this types of feature.
I am not sure but It may be possible in JB Device.
you can add custom tool bar at the top of your view and add back button to custom tool bar to come back to your app. Below to custom tool bar add your webview.Hope it will helps you.
If you are loading the webpage with Safri or you are opening iTunes app with custom schema, it is not possible, because you are leaving the app.
But yes you can do this, If you will load that itunes connect link through web view, and there you can place a custom back button to come back to your previous page.
For Example :
UIWebView *webView=[[UIWebView alloc]init];
[self.view addSubview:webView];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.xyz.com"]]];
Some help please,
I am putting a web app together and I am stuck on a few things.
I have tabviewcontrollers which load different uiwebviews.
Each time I navigate on the app and re-click the tab it remains where I was on that page is there a way to re-load it so it always goes from the orginal ur (not just a refresh)?
Any advice on the best way to handle this would be appreciated.
Thank you
Steve
Load the request in your view controller's viewWillAppear: method.
When you want to refresh, use
[webView reload]
or for if you want t reload with a specific url
NSURL *theURL = [NSURL URLWithString:#"http://urltoreload.html"];
[webView loadRequest:[NSURLRequest requestWithURL:theURL]];
I need to clean the content of UIWebView(in order to reuse it), but I have some authentication handling code in its delegate methods, so I do not want to load an empty page like about:blank to clean it, as it will trigger my authentication handling code. So is there a way for doing this?
(also, by reusing it, I need to put a spinner on top of the web view, and when it loads another page, I don't want the user see the previous loaded page content, so that's why I need to clean it)
Thanks!
You can just use this line of code :
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"about:blank"]]];
Here you will find whole demo
this did the trick for me:
[webView stringByEvaluatingJavaScriptFromString:#"document.open();document.close()"];
Try this out. This worked for me
[self.webView stringByEvaluatingJavaScriptFromString:#"document.body.innerHTML = \"\";"];
If your only problem is that the spinner disappears when you load a blank page, you can use this code in webViewDidFinishLoad:
– (void)webViewDidFinishLoad:(UIWebView *)currentWebView {
if (![currentWebView.request.URL.description isEqualToString: #"about:blank"]) {
self.mySpinner.hidden = YES;
}
}
...then the spinner will go on until your webview is actually done loading.
I'm making an iPhone app using xcode, but whenever the homepage (localHTML) is visited using the backbutton, the list item stays highlighted. My solution to this is to refresh the page whenever the localHTML is visited. Can anyone suggest an easy way of detecting when the url matches localHTML (should I use isFileURL?) Thanks for your help. Also, the list was made with javascript or else I would use deselectRowAtIndexPath.
This is what I came up with, but it doesn't work
-(IBAction)backbutton{
[webView goBack];
NSString *currentURL = webView.request.URL.absoluteString;
if (currentURL = "whatever the file path is") {
[webView reload];
}
is this a valid way to accomplish this? is there a way to get my localhtml's file path by using nslog?
Have you tried having a delay after going back, then refreshing?
eg. after
[webView goBack];
have a delay now using nstimer
then
[webView reload];
For a current project I am embedding a mobile site into an iOS app. I've taken use of the goback() and goforward() functions, with UIWebView. But how would I make a custom function that onClick (or onTouch which ever is the correct term) Sends the UIWebView back to the page initially loaded? Any Help would be much appreciated as I have bene unable to find anything on the web thus far.
Add something like to the 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 at the appropriate position):
- (IBAction)loadPage:(id)sender;
IBOutlet UIWebView *webView;
Then bind the button to loadPage within interface builder,
and bind webView to the UIWebView.
Response to comment:
I created this sample project, hopefully it helps:
- http://dd5.org/static/iPhone_Browser_Sample.zip
Binding the button:
Right-click and drag to the class where you added the code above.
Release the button. Now a little dark-gray panel should appear.
Then click on the loadPage: entry within that panel.
If the code was added correctly, the entry should show up there.