Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Tableview行,更改最后一个单元格将更改第一个单元格_Ios_Swift_Uitableview_Tableview_Tableviewcell - Fatal编程技术网

Ios Tableview行,更改最后一个单元格将更改第一个单元格

Ios Tableview行,更改最后一个单元格将更改第一个单元格,ios,swift,uitableview,tableview,tableviewcell,Ios,Swift,Uitableview,Tableview,Tableviewcell,我在修改单元格约束方面遇到了很多麻烦。我有一个tableview,里面有一个嵌套的单元格和一个按钮 底部的more按钮具有共享单元格底部的约束。还有一个视图隐藏在它后面,带有高度约束,您可以看到它从底部向外窥视 基本上,如果我单击该按钮,两个约束将被更改,单元格将展开 表格视图单元格: @IBAction func expandPress(sender: AnyObject) { if expandButtonBottomConstraint.active { self

我在修改单元格约束方面遇到了很多麻烦。我有一个tableview,里面有一个嵌套的单元格和一个按钮

底部的
more
按钮具有共享单元格底部的约束。还有一个视图隐藏在它后面,带有高度约束,您可以看到它从底部向外窥视

基本上,如果我单击该按钮,两个约束将被更改,单元格将展开

表格视图单元格:

@IBAction func expandPress(sender: AnyObject) {
    if expandButtonBottomConstraint.active {
        self.expandButtonBottomConstraint.active = false
        self.descriptionTextHeightConstraint.constant =      
    self.descriptionTextHeightConstraint.constant * 10          
    self.tableView.tableView.reloadRowsAtIndexPaths([NSIndexPath(forRow: buttonIndex, inSection: 0)], withRowAnimation: UITableViewRowAnimation.Automatic)
    }        
}
TableViewController

override func tableView(tableview: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let eventCell = tableView.dequeueReusableCellWithIdentifier("EventTableViewCell") as! EventTableViewCell
...
eventCell.buttonIndex = indexPath.row
....
self.tableView.layoutIfNeeded()
}

override func viewDidAppear(animated: Bool) {
    self.tableView.reloadData()
}

如果单击第一个事件,它将展开,但如果单击第三个事件,则第三个和第一个将展开。索引行正确地位于正确的行中。如何始终只展开特定行

单元格可以重用,因此您需要跟踪哪些行已展开,哪些行不是单元格本身以外的其他位置。然后在
cellforrowatinexpath
中适当地配置单元格如果唯一改变的是布局,您不需要重新加载单元格,只需调用
tableView.beginUpdate()
endUpdate()
检查一下,您有多少节?还有,为什么您有两次使用RowAnimation:UITableViewRowAnimation.Automatic的2个tableview
self.tableview.tableview.reloadRowsAtIndexPaths([nsIndepath(forRow:buttonIndex,Instition:0)],
单元格可以重用,因此您需要跟踪哪些行已展开,哪些行不是单元格本身以外的其他位置。然后在
cellforrowatinexpath
中适当地配置单元格如果唯一改变的是布局,您不需要重新加载单元格,只需调用
tableView.beginUpdate()
endUpdate()
检查一下,您有多少节?还有,为什么您有两个tableview
self.tableview.tableview.reloadrowsatindexpath([nsindepath(forRow:buttonIndex,instition:0)],带rowanimation:UITableViewRowAnimation.Automatic)