我在第一个视图控制器中有一个 uiwebview,我在第二个视图控制器上有一个 uibutton,当我单击 uibutton 时,我正在更改加载请求。问题是,网址已更改,但 webview 没有重新加载。
第一视图控制器
-(void)viewDidLoad
{
a=@"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];
}
第二视图控制器
- (IBAction)goFirst:(id)sender {
NSString* b=@"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 提前