预期行为
一个点击表格单元格将向上滑动一个视图(高250px)进入视图。点击另一行将更新与所点击的行对应的视图信息。点击同一行将向下滑动视图。
发生错误
的上下文
信息视图有限制,使其位于Superview / Screen底部的顶部。
代码示例
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
self.localTableView.deselectRowAtIndexPath(indexPath, animated: true)
self.mapView.selectAnnotation(self.players[indexPath.row], animated: true)
self.populateInfoView(indexPath.row)
if(self.infoView.frame.origin.y == UIScreen.mainScreen().bounds.size.height){
self.showInfoView(true)
} else if (self.previouslySelectedRow == indexPath.row){
self.hideInfoView(true)
}
self.previouslySelectedRow = indexPath.row
}
func populateInfoView(index: Int){
self.infoCoverImage.image = UIImage(named: "\(self.players[index].profileImage)")
self.infoProfileImage.image = UIImage(named: "\(self.players[index].profileImage)")
self.infoPlayerName.text = self.players[index].name
self.infoTwitterName.text = self.players[index].twitterName
}
func showInfoView(animated: Bool){
let height = self.infoView.frame.size.height
let yPos = UIScreen.mainScreen().bounds.size.height - height
UIView.animateWithDuration(0.33, animations: {
self.infoView.frame.origin.y = yPos
}, completion: { finished in
println("Always called, even if the frame does not move")
})
self.infoVisible = true
}
func hideInfoView(animated: Bool){
let height = self.infoView.frame.size.height
let yPos = UIScreen.mainScreen().bounds.size.height
if(animated == true){
UIView.animateWithDuration(0.25, animations: {
self.infoView.frame.origin.y = yPos
})
} else {
self.infoView.frame.origin.y = yPos
}
self.infoVisible = false
}
任何帮助将不胜感激。谢谢,
答案 0 :(得分:0)
[已解决] - 问题的结果是因为我们使用了frame.origin而不是约束。如果您希望视图保持不变,使用约束。如果您有可重复的类精灵动画,请使用原点