Is it possible to uninstall a button when the device is in landscape?
I would have thought I could uninstall a button in the same way I uninstall a constraint - yet I can't work it out.
Found it in the interface builder:
Here is one way:
@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
}
}
You can remove your button or hide it
btn.removeFromSuperview()
//or
btn.hidden = true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.