2015-06-09 10 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。

相關問題