2016-06-22 13 views
3

セルをクリックすると表示されるポップオーバーがあります。このポップオーバーには、行を持つTableViewがあります。その行をクリックすると、3つの新しい行が表示され、アニメーションが表示されます。そのアニメーションを削除したいと思います。出来ますか ?ここでPopoverでTableView選択でアニメーションを無効にするにはどうすればいいですか?

は私のコードです:

extension PlanningActionTableViewController 
{ 
    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int 
    { 
     return numberOfRows() 
    } 

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell 
    { 
     let cell = tableView.dequeueReusableCellWithIdentifier("ActionCell", forIndexPath: indexPath) as!PlanningActionCell 


     // Info cells 
     if registration == nil 
     { 
      if slot.registrations.count > indexPath.row 
      { 
       let contact = slot.registrations[indexPath.row].contact 
       let name = contact.lastname + " " + contact.firstname 
       cell.actionLabel.text = (name.characters.count > 1 ? name : "Réservation en cours") 
       cell.accessoryType = .DisclosureIndicator 
       cell.imageSymbol.image = UIImage(named: "picto.user.default") 

       return cell 
      } 

      cell.actionLabel.text = "Ajouter" 
      cell.accessoryType = .None 
      cell.imageSymbol.image = UIImage(named: "picto.user.add") 

      return cell 

     } 

     // Actions cell 
     switch indexPath.row 
     { 
     case 0: 
      cell.actionLabel.text = "Détails" 
      cell.accessoryType = .None 
      cell.imageSymbol.image = UIImage(named: "picto.user.details") 

     case 1: 
      var state = "Non" 
      if let contact = registration?.contact 
      { 
       state = (contact.isArrived ? "Oui" : "Non") 
      } 

      cell.actionLabel.text = "Est arrivé: " + state 
      cell.accessoryType = .None 
      cell.imageSymbol.image = UIImage(named: "picto.user.valid") 

     default: 
      cell.actionLabel.text = "Supprimer booking" 
      cell.actionLabel.textColor = UIColor.redColor() 
      cell.imageSymbol.image = UIImage(named: "picto.user.delete") 
      cell.accessoryType = .None 
     } 

     return cell 
    } 
} 

NumberOfRows:ビデオで

func numberOfRows() -> Int 
{ 
    if registration == nil 
    { 
     return slot.subslotsCount 
    } 

    return 3 
} 

例:あなたは

<iframe src="//gifs.com/embed/1wvE6R" frameborder="0" scrolling="no" width='480' height='220.7665505226481' style="-webkit-backface-visibility: hidden;-webkit-transform: scale(1);" ></iframe>

+1

まず、アニメーションの種類は、新しい行のポップオーバーや外観を拡張するか、あるいはその両方ですか?第2に、 'cellForRowAtIndexPath'メソッド自体は行アニメーションの責任を負いません。データソースを拡張するコードを追加します。つまり、新しい行を挿入したり、' numberOfRows'の値を変更したりします。 –

+0

新しい行の外観です。 3行(またはそれ以上)を表示すると、下に向かって増加しているポップオーバーのアニメーションがあります。 – Claudio

+2

アニメーションが必要ない場合は、必要なポップオーバーのコンテンツサイズを計算し、手動で設定し、アニメーションなしでデータソースの更新をトリガーします。 –

答えて

1

RのviewDidLoad、falseにアニメーションを設定します。

UIView.setAnimationsEnabled(false) 
+0

ありがとうございます。 – Claudio

+0

これは、UIView静的呼び出しを介して実行される*すべての*アニメーションを無効にすることに注意してください。おそらくあなたが望むものではありません。 – NRitH

0

ます(現在では非推奨)UIPopoverControllerを使用していますか?もしそうなら、それにsetPopoverContentSize(_ size: CGSize, animated animated: Bool)と呼んで、animated引数のためにfalseを渡すことができます。テーブルが3行で表示されるサイズを計算するだけです。

モーダルプレゼンテーションスタイルの通常のUIViewControllerを使用している場合は、コンテンツのサイズを計算されたテーブルサイズに設定できます。

+0

mmm ok私はそれを確認します。ありがとう:D – Claudio

関連する問題