iOS Push to TabBarController

2019-09-02 13:52发布

i have several viewcontrollers, and at the last viewcontroller, i want when the users click on a button present in this view, he goes on a other view controller which contains tabbarcontroller. Example

For example, i've something like this :

How can i go from the first view, to the tab bar controller ?

EDIT : i tried to just set a push from the button to the tab bar controller, but it's not runnin g correctly.

2条回答
Deceive 欺骗
2楼-- · 2019-09-02 14:06

Create a segue in the Interface Builder, give it a unique identifier, then call that segue in your code using

[self performSegue:@"segueIdentifier" sender:self];
查看更多
Melony?
3楼-- · 2019-09-02 14:13

You have to embed the button's view controller in a UINavigationController, otherwise you will get an error like this:

Terminating app due to uncaught exception 'NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController.'

Once I put it in a UINavigationController, it transitioned just fine in my tests.

If you do not want a UINavigationController, you can set the segue to Modal, and it should also transition to the Tab Bar, but modally.

查看更多
登录 后发表回答