Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode 6.3.1,Swift,iOS 8界面构建器-安装时卸载按钮_Ios_Swift_Xcode6 - Fatal编程技术网

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
    }       
}

在界面生成器中找到它:

  • 将界面生成器设置为横向(wAny hCompact)
  • 选择按钮(视图控制器>视图>按钮)
  • 属性检查器(滚动到底部)
  • 取消选中“已安装”

  • 您可以删除或隐藏按钮

    btn.removeFromSuperview()
    //or
    btn.hidden = true
    

    谢谢你的密码回答。我强迫自己在这个项目上学习界面生成器。谢谢你提供代码建议。我正在尝试使用界面生成器来解决这个问题。