Swift 4 带 TableView 的 SegmenterControl
Swift 4 SegmenterControl with TableView
我做一个社交app,现在想出个好看的。我想从 segmentedCntrol 更改标签联系人/房间。我怎样才能用正确的形式做到这一点?我有两种方法...清除联系人 table 查看并用房间数据填充它。或者使用 table 视图隐藏视图并使用新的 tableView.
显示另一个视图
您应该创建 2 个 tableViewCells 并根据所选段
在 cellForRowAt
中切换它们
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if mySegment.selectedSegmentIndex == 0
{
let cell = tableView.dequeueReusableCell(withIdentifier:CellIdentifier1) as! Cell1
// setup here
}
else{
let cell = tableView.dequeueReusableCell(withIdentifier:CellIdentifier2) as! Cell2
// setup here
}
}
我做一个社交app,现在想出个好看的。我想从 segmentedCntrol 更改标签联系人/房间。我怎样才能用正确的形式做到这一点?我有两种方法...清除联系人 table 查看并用房间数据填充它。或者使用 table 视图隐藏视图并使用新的 tableView.
显示另一个视图您应该创建 2 个 tableViewCells 并根据所选段
在cellForRowAt
中切换它们
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if mySegment.selectedSegmentIndex == 0
{
let cell = tableView.dequeueReusableCell(withIdentifier:CellIdentifier1) as! Cell1
// setup here
}
else{
let cell = tableView.dequeueReusableCell(withIdentifier:CellIdentifier2) as! Cell2
// setup here
}
}