我有一个UIView,它会在按下按钮时向下滑动,然后在另一个按钮上向上滑动。它完全向下滑动,但是当我尝试点击合约按钮时,我无法单击它,但它会单击视图下方的集合视图单元格。我无法弄清楚为什么它会正常滑下,但它不能发挥我的预期效果。非常感谢!
@IBAction func onExpandButtonPressed(sender: UIButton) {
let xPosition = expandingView.frame.origin.x
//View will slide to 40 px higher bottom of the screen
let yPosition = expandingView.frame.maxY - 40
let height = expandingView.frame.size.height
let width = expandingView.frame.size.width
UIView.animateWithDuration(0.5, animations: {
self.expandingView.frame = CGRectMake(xPosition, yPosition, height, width)
self.expandButton.hidden = true
self.contractButton.hidden = false
})
}
@IBAction func onContractButtonPressed(sender: UIButton) {
let xPosition = expandingView.frame.origin.x
let yPosition = expandingView.frame.origin.y
let height = expandingView.frame.size.height
let width = expandingView.frame.size.width
UIView.animateWithDuration(1.0, animations: {
self.expandingView.frame = CGRectMake(xPosition, yPosition, height, width)
self.expandButton.hidden = false
self.contractButton.hidden = true
})
}
答案 0 :(得分:0)
也许是因为视图已经滑过按钮。因此,尝试在按钮操作中使用以下内容,该操作将滑过非工作按钮:
self.view.bringSubViewToFront(buttonName)
如果在按钮Action中放置一个NSLog,它可以帮助确定是否正在调用该函数。