【发布时间】:2018-05-14 08:37:03
【问题描述】:
我的新应用遇到问题。我开发了很多应用程序,但我第一次遇到这个问题。为了测试我的应用程序,我使用的是 Apple iPad Mini 4。 我有一个新的空项目。我只添加了一个 UIButton。但是当我构建这个项目,成功构建并且应用程序正在运行时,2 秒后 UIButton 消失了。当我使用 iPad 或 iPhone 模拟器时,按钮永远存在。没有出现错误,所以我真的不知道发生了什么。有人遇到类似问题吗?
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func example(_ sender: UIButton) {
print("Hello")
}
}
【问题讨论】:
-
请显示一些代码
-
你是否给 iPad 的按钮设置了正确的约束?
-
是的,我有正确的约束。我可以看到按钮,但 2 秒后它消失了。