简体   繁体   中英

Push a new view on button tap

Can't seem to figure this out. I'm attempting to load a UIView (preferably sliding in from the right) on button tap but it isn't changing after the first page.

  1. I click the register button on the settings page and it loads the first register page, then on the first register page, when I click the continueButton to load the second page it wont do anything at all..

SettingsPage.m :

- (void)regsiterButton:(UIButton *)standardButton {
    MAINVIEWCONTROLLER.mainView = [[RegisterStep1 alloc] initWithFrame:MAINVIEWCONTROLLER.mainView.frame];
}

RegisterStep1.m - Attempting to load the next register page, but it isn't working:

- (void)continueButton:(UIButton *)standardButton {
    MAINVIEWCONTROLLER.mainView = [[RegisterStep2 alloc] initWithFrame:MAINVIEWCONTROLLER.mainView.frame];
}

Assuming RegisterStep1 is a UIViewController subclass, you want to use UINavigationController 's pushViewController:animated: method, which does the default transition from the right.

If you don't have a UINavigationController already set up, you'll want to wrap SettingsPage in one via initWithRootViewController: before using it.

This Apple guide describes how navigation controllers fit into the overall navigation of an app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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