我在第一個viewcontroller中有一個uiwebview,並且在第二個控制器上有一個uibutton,當我點擊uibutton時,我正在改變加載請求。事情是,網址改變了,但webview沒有重新加載。如何從另一個視圖控制器加載uiwebview
FirstViewController
-(void)viewDidLoad
{
[email protected]"http://www.google.com";
[self loadWebview];
}
-(void)loadWebview
{
a=[[NSUserDefaults standardUserDefaults]objectForKey:@"key"];
NSLog(@"current URL:%@",a);
self.myweb.delegate=self;
[self.myweb loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:a]]];
}
- (IBAction)goSecond:(id)sender
{
SecondViewController *vv=[[SecondViewController alloc]init];
[self.navigationController pushViewController:vv animated:YES];
}
SecondViewController
- (IBAction)goFirst:(id)sender {
NSString* [email protected]"http://www.apple.com";
[[NSUserDefaults standardUserDefaults] setObject:b forKey:@"key"];
FirstViewController *vv=[[FirstViewController alloc]init];
[vv loadWebview];
[self.navigationController popViewControllerAnimated:YES];
}
Result is:
current URL:http://www.google.com
current URL:http://www.apple.com
但是WebView中沒有加載,我想加載www.apple.com.Thanks提前
看到我的代碼,我不想看到第二個視圖controller.when我點擊第二個viewcontroller的uibutton它去第一個視圖,我想看看 - – IosAdvocate
簡要解釋 – Sierra