我想为 ipad 和 iphone 使用不同的 Storyboard。我按照这个 tutorial 成功地做到了.
但我想知道如何在 iPad 和 iPhone 中为 Button
调用相同的操作。
最佳答案
创建一个 IBAction
并在 Storyboard中为其分配 button
,现在如果你想区分它是从 iphone
调用还是从 ipad
您可以在 IBAction
中为其添加条件。
@IBAction func buttonClick(sender: UIButton) {
if (UIDevice.currentDevice().userInterfaceIdiom == .Pad) {
// It is from iPad
}
else {
// It is from iPhone
}
}
关于iphone - 为 iPhone 和 iPad 使用不同的 Storyboard时如何为按钮设置 Action ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38865581/