Xcode 6.3.1,Swift,iOS 8界面构建器-安装时卸载按钮
当设备处于横向时,是否可以卸载按钮 我本以为我可以像卸载约束一样卸载一个按钮,但我无法解决它。这里有一种方法:Xcode 6.3.1,Swift,iOS 8界面构建器-安装时卸载按钮,ios,swift,xcode6,Ios,Swift,Xcode6,当设备处于横向时,是否可以卸载按钮 我本以为我可以像卸载约束一样卸载一个按钮,但我无法解决它。这里有一种方法: @IBOutlet weak var btn_MyButton: UIButton! override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) { switch UIDevice.currentDevice().orientation{
@IBOutlet weak var btn_MyButton: UIButton!
override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) {
switch UIDevice.currentDevice().orientation{
case .LandscapeLeft:
btn_MyButton.hidden = true
case .LandscapeRight:
btn_MyButton.hidden = true
default:
btn_MyButton.hidden = false
}
}
在界面生成器中找到它:
您可以删除或隐藏按钮
btn.removeFromSuperview()
//or
btn.hidden = true
谢谢你的密码回答。我强迫自己在这个项目上学习界面生成器。谢谢你提供代码建议。我正在尝试使用界面生成器来解决这个问题。