0
我怎樣才能顯示另一個(其他城市)的ViewController當我選擇一個選擇器。我有一個選擇器(簡單,中間,難),當我選擇一個選擇器,我點擊一個buton我想去特定的視圖控制器(我有3視圖控制器(一個爲簡單,一個爲中間,另一個用於硬) 請幫我我怎樣才能顯示另一個(其他城市)的ViewController當我選擇一個選擇器
我怎樣才能顯示另一個(其他城市)的ViewController當我選擇一個選擇器。我有一個選擇器(簡單,中間,難),當我選擇一個選擇器,我點擊一個buton我想去特定的視圖控制器(我有3視圖控制器(一個爲簡單,一個爲中間,另一個用於硬) 請幫我我怎樣才能顯示另一個(其他城市)的ViewController當我選擇一個選擇器
在按一下按鈕,就可以出現或推視圖控制器如果您有賽格瑞連接它,你可以這樣做:
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)
尼克Catib謝謝你,但你可以使用快捷 –
當然,給我爲10分鐘展示給我 – Miknash
很抱歉,如果你把它給了我兩個可能性還是什麼我沒undersatnd ? –