我想创建一个有两个按钮的基本iOS应用。点击第一个按钮以显示视图控制器1,点击第二个按钮以显示视图控制器2.
如何通过快速代码执行此操作。
我将第一个按钮连接到根视图控制器上的以下代码:
@IBAction func showViewOneTapped(_ sender: Any) {
// this is where I need help I think
}
我还为每个想要显示的视图控制器创建了shell swift文件。
答案 0 :(得分:-1)
喜欢这个
keys
答案 1 :(得分:-1)
试试这个 -
@IBAction func showViewOneTapped(_ sender: Any) {
let storyBoard : UIStoryboard = UIStoryboard(name: "YourStoryBoardName", bundle:nil)
let nextViewController = storyBoard.instantiateViewController(withIdentifier: "YourIdentifierName") as! yourClassname(e.g PhoneNoDropDownViewController)
self.present(nextViewController, animated:true, completion:nil)
}
@IBAction func showViewTwoTapped(_ sender: Any) {
let storyBoard : UIStoryboard = UIStoryboard(name: "YourStoryBoardName", bundle:nil)
let nextViewController = storyBoard.instantiateViewController(withIdentifier: "YourIdentifierName") as! yourClassname(e.g PhoneNoDropDownViewController)
self.present(nextViewController, animated:true, completion:nil)
}
答案 2 :(得分:-1)