当我选择一个选择器时,如何显示另一个(更改)ViewController。
我有一个选择器(简单,中间,硬)当我选择一个选择器并且我点击一个按钮我想去特定的视图控制器(我有3个视图控制器(一个用于简单,一个用于中间)而另一个是硬的) 请帮帮我
答案 0 :(得分:0)
单击按钮,可以显示或推送视图控制器。如果您已将其与segue连接,则可以执行以下操作:
if(easySelected)
[self performSegueWithIdentifier:@"easyOne" sender:self];
else if
...
如果您有导航控制器或想要呈现它,您可以这样做:
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
EasyViewConroller *cont = [story instantiateInitialViewController];
// or EasyViewConroller *cont = [story instantiateViewControllerWithIdentifier:@"YourIdent"];
// in former solution you have to set that identifier in the code/storyboard
// navigation/push
self.navigationController pushViewController:cont animated:YES];
// if you want to present it
[self presentViewController:cont animated:YES completion:nil];
编辑:
if(easySelected){
self.performSegueWithIdentifier("easyOne" sender:self)
{
else if{
...
}
//If you have navigation controller or want to present it you can do:
var tempStory = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
var tempVC = tempStory.instantiateInitialViewController() as! EasyViewController
//present
self.presentViewController(tempVC, animated: true)
//push
self.navigationController?.pushViewController(tempVC, animated: true)