2015-06-09 11 views
0

预期行为
一个轻触表格单元格将滑视图(以250像素高)进入视野。点击另一行将更新对应于所点击的行的视图信息。点击同一行将向下滑动视图。frame.origin更改错误时表单元格选择


错误发生时,

  1. 第一抽头被识别(为frame.origin和数学的变化),但这个视图举动。需要对同一单元格进行第二次敲击才能使View向上滑动(对于frame.origin,发生同样的数学运算)。
  2. 点击另一行可将查看移回到屏幕底部,即使未调用操作以隐藏信息视图。


语境
的信息视图中有一个地方是顶在上海华/屏幕底部的约束。


代码示例

 
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

[已解决] - 问题是因为我们使用了frame.origin而不是约束。如果您希望视图持续存在,使用约束。如果您有可重复的精灵动画,请使用origin。

相关问题