【发布时间】:2017-11-30 07:30:07
【问题描述】:
我有带问题视图的表格视图单元格,每个问题包含三个选项注释视图、图像视图和操作项视图。一个单元格包含更多按钮。使用这个更多按钮,我必须(显示/隐藏)注释视图、图像视图、操作项视图,默认情况下单元格加载问题视图。
【问题讨论】:
-
@Rajesh 这很好用。但仅适用于具有 iOS 9 及更高版本的设备(因为堆栈视图)。
标签: ios uitableview xcode8
我有带问题视图的表格视图单元格,每个问题包含三个选项注释视图、图像视图和操作项视图。一个单元格包含更多按钮。使用这个更多按钮,我必须(显示/隐藏)注释视图、图像视图、操作项视图,默认情况下单元格加载问题视图。
【问题讨论】:
标签: ios uitableview xcode8
用于展开和折叠tableviewcell
var selectedIndex = ""
在您的viewDidLoad 中添加以下行
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 300 //give maximumheight you expect in tableviewcell
将NotesView高度约束出口设置为UITableViewCell
将此行添加到您的cellForRowAt
cell.moreBtn.tag = indexPath.row
cell.moreBtn.addTarget(self, action: #selector(self.moreClicked(_:)), for: .touchUpInside)
if selectedIndex == "\(indexPath.row)" {
cell.notesViewHgt.constant = 100 //give height you required
} else {
cell.noteViewHgt.constant = 0
}
然后将此函数添加到您的视图控制器中
func moreClicked(_ sender:UIButton){
self.selectedIndex = "\(sender.tag)"
self.tableView.reloadData()
}
希望对你有帮助
【讨论】: