简体   繁体   English

返回到IOS上未访问的页面

[英]Go back to unvisited page on IOS

I am unfamiliar with IOS development, so probably a simple question: is it possible that the user presses the "back" button on the top, and go to a (so far) non-visited page? 我不熟悉IOS开发,因此可能是一个简单的问题:用户是否有可能按下顶部的“后退”按钮,然后转到(到目前为止)未访问的页面? Here is the picture: 这是图片: 在此处输入图片说明

On window "1" user presses a button, the next window is "2". 在窗口“ 1”上,用户按下一个按钮,下一个窗口是“ 2”。 But here, if user presses the "back" button, go to page "3" (which was never opened so far)? 但是在这里,如果用户按下“后退”按钮,则转到页面“ 3”(到目前为止从未打开过)?

Thanks 谢谢

You can simply redefine the back button by creating a new one in your second view controller like this : 您可以通过在第二个视图控制器中创建一个新按钮来简单地重新定义后退按钮,如下所示:

- (void)viewDidLoad {
    [super viewDidLoad];

    UIButton *backButton = [[UIButton alloc] initWithFrame: CGRectMake(0, 0, 60.0f, 30.0f)];
    [backButton setTitle:@"Back" forState:UIControlStateNormal];
    [backButton setTitleColor:self.view.tintColor forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(pushToNextController) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = backButtonItem;
}

- (void)pushToNextController {
    UIViewController *thirdViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"thirdViewController"];
    [self.navigationController pushViewController:thirdViewController animated:YES];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM