扩展的单元格未被单击

时间:2016-05-11 10:08:42

标签: ios uitableview uicollectionview

在我的应用中,我有tableview个自定义单元格,其中包含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

        }

因此,如果我在heightForRowAtIndexPath中给出固定高度200,则单击工作正常,但如果没有给定固定点击不起作用

1 个答案:

答案 0 :(得分:0)

检查已扩充单元格的高度或将备用背景颜色设置为单元格。您将看到该单元格没有显示CollectionView所需的高度。因此,您无法单击单元格底部的按钮。

相关问题