如何从 iOS 中的 Web 视图返回?
How to get back from the web view in iOS?
我是 iOS 的新手。在我的项目中有两个视图控制器,即 FirstViewController 和 Webviewcontroller。在我的 firstviewcontroller 中,我设置了一个按钮。当我单击该按钮时,它会移动到 webviewcontroller 并加载一个示例网站。在我的 webviewcontroller 的顶部导航栏中有两个用于处理网站页面的按钮,代码如下
//for handle the previous page
- (void) buttonGoBack
{
if ([_webView canGoBack]) {
[_webView goBack];
}
}
//for handle the next page
- (void) buttonGoForward
{
if ([_webView canGoForward]) {
[_webView goForward];
}
}
现在我想要的是……当我单击顶部的上一个按钮时,它会移动到 Web 视图的上一页。我需要的是当 Web 视图完成他们的页面时,当我单击上一页时,它转到上一个视图 controller.this 是我的需要。提前抱歉english.thanks
检查是否可以返回 returns 否弹出 viewController by [self.navigationController popViewControllerAnimated:YES
或者如果有 prsentViewController 然后调用 [self dismissViewControllerAnimated:YES completion:nil]
- (void) buttonGoForward
{
if ([_webView canGoForward])
{
[_webView goForward];
}
else
{
// pop webviewcontroller or dismiss depending on how you have launched webviewcontroller screen
}
}
这个怎么样?
//for handle the previous page
- (void) buttonGoBack {
if ([_webView canGoBack]) {
[_webView goBack];
} else {
[self.navigationController popViewControllerAnimated:YES];
}
}
我是 iOS 的新手。在我的项目中有两个视图控制器,即 FirstViewController 和 Webviewcontroller。在我的 firstviewcontroller 中,我设置了一个按钮。当我单击该按钮时,它会移动到 webviewcontroller 并加载一个示例网站。在我的 webviewcontroller 的顶部导航栏中有两个用于处理网站页面的按钮,代码如下
//for handle the previous page
- (void) buttonGoBack
{
if ([_webView canGoBack]) {
[_webView goBack];
}
}
//for handle the next page
- (void) buttonGoForward
{
if ([_webView canGoForward]) {
[_webView goForward];
}
}
现在我想要的是……当我单击顶部的上一个按钮时,它会移动到 Web 视图的上一页。我需要的是当 Web 视图完成他们的页面时,当我单击上一页时,它转到上一个视图 controller.this 是我的需要。提前抱歉english.thanks
检查是否可以返回 returns 否弹出 viewController by [self.navigationController popViewControllerAnimated:YES
或者如果有 prsentViewController 然后调用 [self dismissViewControllerAnimated:YES completion:nil]
- (void) buttonGoForward
{
if ([_webView canGoForward])
{
[_webView goForward];
}
else
{
// pop webviewcontroller or dismiss depending on how you have launched webviewcontroller screen
}
}
这个怎么样?
//for handle the previous page
- (void) buttonGoBack {
if ([_webView canGoBack]) {
[_webView goBack];
} else {
[self.navigationController popViewControllerAnimated:YES];
}
}