简体   繁体   中英

Unwind a Modal UINavigationController to another ViewController

I am trying to segue back to another UIViewController after modally presenting a UINavigationController and with it a root ViewController . What I want to happen is for a button to unwind from the root VC of the UINavigationController and return to the initial UIViewController that presented it. I have the unwind method written in the destination VC and button is hooked up to the Exit point of the VC. But when I press the button, nothing happens. Can someone explain what I am doing wrong? Any advice is appreciated.

Storyboard:

Storyboard

Code:

-(IBAction)unwindToClockView:(UIStoryboardSegue*)sender;
{
    NSLog(@"Back to Clock View");
}

Additional code can be found here: https://github.com/xinkecf35/TrafficAlarmClock

Okay, I have a solution. It just involves programmatically calling a method trigger by the button that outright dismisses the view controller. The method is below.

-(IBAction)dismissSettings:(id)sender
{
    [self dismissViewControllerAnimated:TRUE completion:nil];
}

If anyone can present a solution that uses Storyboards as well, it will be greatly appreciated.

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