2015-10-29 13 views
0

我正在開發一個簡單的遊戲。我創建了一個打開自定義警報視圖的暫停按鈕(我使用了vikmeup's SCLAlertView)。在這個警報(view img)我希望這個按鈕之一打開另一個名爲MenuViewController的ViewController,其中包括主菜單。那可能嗎?我怎樣才能爲segue/unwind分配一個標識符?使用自定義警報視圖中的按鈕在Swift中的另一個ViewController中繼續遊戲

這是我的代碼現在:

@IBAction func menuButton(sender: AnyObject) { 
    let alert = SCLAlertView() 
    alert.addButton("button 1", target:self, selector:Selector("firstButton")) 
    alert.showSuccess(kSuccessTitle, subTitle: kSubtitle) 
} 

回答

1

你是什麼firstButton功能?如果你在故事板創建MenuViewController,那麼你就可以實現這樣的功能:

func firstButton() { 
    let menuVC = self.storyboard!.instantiateViewControllerWithIdentifier("MenuViewControllerIdentifier") 
    self.showViewController(menuVC, sender: self) 
} 
0

試試這個,

1)添加特定的按鈕,按鈕動作。

let alert = SCLAlertView() 
alert.addButton("First Button", target:self, selector:Selector("firstButton")) // action for first button 
alert.addButton("Second Button") { 
print("Second button tapped") 
} 
alert.showSuccess(kSuccessTitle, subTitle: kSubtitle) 


func firstButton() 
{ 
     //Do something 
    let storyboard = UIStoryboard(name: "Main",bundle: nil) 
    let vc = storyboard.instantiateViewControllerWithIdentifier("Identifier_name") 
    self.presentViewController(vc, animated: true, completion: nil) 

} 
+0

正常工作... :) tnks –

相關問題