简体   繁体   中英

Programmatically push to view controller [2] in a navigation stack, and unwind to [1]

I have a UITableViewController populated with a list of users. The UITableViewController is embedded in a navigation controller. Tapping a row in the table view pushes the view controller userVC . Tapping the a + button on userVC pushes a view controller addAlarmVC . (See image below)

DEFAULT BEHAVIOR

默认行为

QUICK ACTION

快速行动行为

I want to implement a quick action from my users table view that will allow me to programmatically push addAlarmVC directly, and unwind or "go back" to userVC . I want to have both navigation routes, Default, and Quick Action.

Essentially, my question is: In a navigation stack with [0,1,2] how do I push from 0 to 2 in a way that allows me to unwind to 1? I am using storyboards, but if the problem can be solved programmatically I would prefer such.

You can try this ( give each VC a storyboard identifier in IB and load it )

let userVC =  ////// self.storyboard.instan
let addAlarmVC =  ////// self.storyboard.instan
self.navigationController.setViewControllers([self,userVC,addAlarmVC],animated:true) 

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