Reputation: 1423
i want to call two url in one webview one after the another but how i know i can load one url in webview but to call two url please help me one this how to timeinterval on both the url this is mu single url if but i have to give here two url the how to give and call them
- (void)viewDidLoad {
[super viewDidLoad];
CheapFlightsAppDelegate* app=(CheapFlightsAppDelegate*)[[UIApplication sharedApplication]delegate];
self.navigationController.navigationBarHidden = true;
NSLog(@"Book: %@",app.selectedOutgoingFlight.FlightKey);
NSLog(@"Book: %@",app.selectedInComingFlight.FlightKey);
NSString *hel = @"http://www.bookryanair.com/SkySales/FRSelect.aspx?AvailabilityInputFRSelectView %24ButtonSubmit=Select%20and%20Continue&AvailabilityInputFRSelectView%24m arket1=";
NSString *hel1 =[NSString stringWithFormat:@"%@&",app.selectedOutgoingFlight.FlightKey];
NSString *hel2 = @"AvailabilityInputFRSelectView%24market2=";
NSString *hel3 = [NSString stringWithFormat:@"%@&",app.selectedInComingFlight.FlightKey];
NSString *hel4 = @"__EVENTARGUMENT=&__EVENTTARGET=";
NSString *urlAddress = [NSString stringWithFormat:@"%@%@%@%@%@",hel,hel1,hel2,hel3,hel4];
[spinner startAnimating];
spinner.hidden = NO;
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
NSLog(@"Book: %@",urlAddress);
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
webView.delegate = self;
}
Upvotes: 1
Views: 869
Reputation: 2144
use this method
NSURLRequest *request=[[NSURLRequest alloc] initWithURL:[[NSURL alloc] initWithString:@"http://stackoverflow.com/questions/7670889/how-to-call-two-url-in-one-webview-in-iphone/7670992#7670992"]];
[webView loadRequest:request];
[self performSelector:@selector(loadAnother:) withObject:nil afterDelay:10];
-(IBAction)loadAnother:(id)sender{
NSURLRequest *requests=[[NSURLRequest alloc] initWithURL:[[NSURL alloc] initWithString:@"http://stackoverflow.com/questions/7683196/uitableview-with-text-that-is-both-right-aligned-and-indented"]];
[webView loadRequest:requests];
}
Upvotes: 2
Reputation: 2139
In "webViewDidFinishLoad" delegate method get the current URL thats loaded using
currentURL = webView.request.URL.absoluteString;
Then check if it matches with your first URL and if it does, Load the second URL that you need to call. If you want, call this second URL after some time using a timer.
Upvotes: 0
Reputation: 17877
Set new url
of NSURLRequest
and call [webView loadRequest:requestObj];
after any time interval you want again.
NSTimer will help you to call method after some interval.
// after loading first url:
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:60 target:self selector:@selector(loadNewUrl:) userInfo:nil repeats:NO];
//somewhere in delegate define selector
- (IBAction)loadNewUrl:(NSTimer *)timer
{
NSURL *url = [NSURL URLWithString:@"http://www.apple.com/stevejobs"];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
}
UPDATED: Implement in your `` methods to detect when webview finished loading first url:
- (void)webViewDidFinishLoad:(UIWebView *)webView;
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error;
Upvotes: 1