2016-05-11 17 views
2

私のアプリではcollectionviewbuttonが入っているカスタムセルを持つtableviewがあります。私のアプリに拡張機能を実装したいのですが、コレクションビューのデータとボタンはクリックされていません。テーブルの高さを固定すると、コレクションビューとボタンがクリックされるようになりましたが、拡張高さを計算してクリックビューに割り当てません。拡張されたセルがクリックされていない

コード

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 

      let cell = self.tableView.cellForRowAtIndexPath(indexPath) as! YourBudgetTableViewCell 

      cell.budgetIcon.image = UIImage(named: "ic_your_budget_close"); 

      // cell.collectionView.tag = indexPath.row; 

      // cell.setCollectionViewDataSourceDelegate(self, forRow: indexPath.row) 

      cell.selected=true; 

      isCellSelected = indexPath.row; 

      self.tableView.beginUpdates(); 

      self.tableView.endUpdates(); 

     } 



    func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) { 

      let cell = self.tableView.cellForRowAtIndexPath(indexPath) as! YourBudgetTableViewCell 

      cell.budgetIcon.image = UIImage(named: "ic_your_budget_expand"); 

      isCellSelected = -1; 

      self.tableView.beginUpdates(); 

      self.tableView.endUpdates(); 



     } 

func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? { 



     let selectedCell = tableView.cellForRowAtIndexPath(indexPath)! 



     if selectedCell.selected { 

      self.tableView.deselectRowAtIndexPath(indexPath, animated: false); 

      self.tableView(self.tableView, didDeselectRowAtIndexPath: indexPath) 

      return nil; 

     } 



     return indexPath 

    } 



    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { 



      if isCellSelected == indexPath.row 

      { 

       return 200; 

      } 

      else 

      { 

       return 44; 

      } 

      // return 200; 

     } 

     func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 



      return self.listBudget.count 

     } 

だから私は固定の高さを与える場合は、クリックが正常に動作しますが、与えられていない場合は、固定のクリックが費やされ、細胞またはセットのために高さ

答えて

0

チェックを働いていないheightForRowAtIndexPathで200を言います背景色をセルに代えます。セルには、CollectionViewを表示するのに必要な高さがないことがわかります。そのため、セルの下部にあるボタンをクリックすることはできません。

+0

また、私はコレクションビューのセルをクリックすることもできません。 –

+0

セルclipToBoundsのプロパティをYESに設定し、ボタンがまだ見えるかどうか教えてください。 – Surjeet

+0

まだクリックできません:( –

関連する問題