基本上我试图调用后退按钮以转到上一个网页,但它似乎无法这样做。我不确定我是否遗漏了一个小细节。当我在原始页面上单击一个链接然后单击另一个链接然后按下后退按钮以到达第一个链接时,这似乎有效,但不会返回到原始页面(希望有意义)。
- (void)viewDidLoad {
[super viewDidLoad];
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 119, self.view.bounds.size.width, self.view.bounds.size.height - 165)];
webView.backgroundColor = [UIColor whiteColor];
webView.userInteractionEnabled = NO;
webView.opaque = NO;
[webView loadHTMLString:self.item.description baseURL:[NSURL URLWithString:self.item.link]];
[self.view addSubview:webView];
webView.delegate = self;
webView.scalesPageToFit = YES;
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
backButton.frame = CGRectMake(0, 0, 34, 34);
[backButton setImage:[UIImage imageNamed:@"back_arrow"] forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:backButton];
}
- (void)back {
[webView goBack];
}
最佳答案
如果您没有在 .h 文件中提供 UIWebViewDelegate,那么首先提供它,如果您的问题没有解决,那么只需注释这一行,然后检查:
webView.userInteractionEnabled = NO;
我运行您的代码一切正常,但我运行您的代码并在该行添加注释。
关于iphone - Webview 不会返回到原始页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15419016/