我有三个不同的tableview单元格,每个将根据所选的分段控制索引显示,但当索引为1时,表格视单元具有自动尺寸(高度),首先无法滚动但是当我更改时分段控制索引和表视图在单击另一个索引后重新加载,然后单击返回1表示视图滚动,但在最初加载时或第一次单击该索引时不滚动。其他2个tableview单元格具有固定高度。
@IBAction func changed(sender: UISegmentedControl) {
setabs = seg.selectedSegmentIndex
if setabs == 0 {
cc = "gr"
}else if setabs == 1 {
cc = "sc"
}else if setabs == 2 {
cc = "us"
}
setab.reloadData()
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell : Tab?
if cc == "gr" {
setab.rowHeight = 82
cell = self.setab.dequeueReusableCellWithIdentifier(cc!, forIndexPath: indexPath) as! Tab
cell!.label2.text = text1[indexPath.row]
} else if cc == "sc" {
setab.rowHeight = UITableViewAutomaticDimension
setab.estimatedRowHeight = 300
cell = self.setab.dequeueReusableCellWithIdentifier(cc!, forIndexPath: indexPath) as! Tab
cell!.label2.text = text2[indexPath.row]
} else if cc == "us" {
setab.rowHeight = 70
cell = self.setab.dequeueReusableCellWithIdentifier(cc!, forIndexPath: indexPath) as! Tab
cell!.label3.text = text3[indexPath.row]
}
return cell!
}