【发布时间】:2017-06-30 04:53:28
【问题描述】:
我有一个应用程序。我认为其中两种观点都有问题。第一个视图有三个按钮,一个排列在另一个下方。单击这三个中的任何一个将带我们进入具有 3 个 tableview 单元格的第二个视图。
问题是,如果我们转到第二个视图并返回第一个视图,第一个视图中的按钮是不可点击的。我正在附加两个视图的屏幕。
注意:表格视图单元格是可点击的。我们按下关闭按钮返回第一个视图。在第二个视图的左上角。
**问题简而言之:如果我们去视图2,点击'X'关闭按钮,视图1中的三个按钮,即fb、G+和Email都不能点击。 **
这是第一个视图中三个按钮的代码。
@IBAction func firstBtnAction(_ sender: Any) {
let bounds = self.firstBtn.bounds
UIView.animate(withDuration: 1.0, delay: 0.0, usingSpringWithDamping: 0.2, initialSpringVelocity: 10, options: [], animations: {
self.firstBtn.bounds = CGRect(x: bounds.origin.x - 20, y: bounds.origin.y, width: bounds.size.width + 20, height: bounds.size.height)
self.firstBtn.isEnabled = false
}, completion: nil)
goaltype = "Conversion"
UserGoal()
}
@IBAction func secondBtnAction(_ sender: Any) {
let boundss = self.secondBtn.bounds
UIView.animate(withDuration: 1.0, delay: 0.0, usingSpringWithDamping: 0.2, initialSpringVelocity: 10, options: [], animations: {
self.secondBtn.bounds = CGRect(x: boundss.origin.x - 20, y: boundss.origin.y, width: boundss.size.width + 20, height: boundss.size.height)
self.secondBtn.isEnabled = false
}, completion: nil)
goaltype = "Engagement"
UserGoal()
}
@IBAction func thirdBtnAction(_ sender: Any) {
let bounds3 = self.thirdBtn.bounds
UIView.animate(withDuration: 1.0, delay: 0.0, usingSpringWithDamping: 0.2, initialSpringVelocity: 10, options: [], animations: {
self.thirdBtn.bounds = CGRect(x: bounds3.origin.x - 20, y: bounds3.origin.y, width: bounds3.size.width + 20, height: bounds3.size.height)
self.thirdBtn.isEnabled = false
}, completion: nil)
goaltype = "Storytelling"
UserGoal()
}
第二个视图表视图单元格有一个小动画。
编辑 1:当我尝试添加 isEnabled = true 时,该按钮是可点击的。但是,由于动画,它会在每次点击时不断扩展。看图:
如何使按钮可点击?
【问题讨论】:
-
试试这个,在你的第一个视图控制器中设置视图中按钮 TRUE 的用户交互将出现方法。可能会有帮助。
-
你如何在这两个视图之间导航??
-
从第一到第二——我们执行一个segue。从第二到第一,关闭视图控制器
-
为什么要为所有按钮设置
isEnabled = false?返回第一个视图时启用它 -
删除这一行 ->
self.thirdBtn.isEnabled = false并尝试