Reputation: 641
I have gotten to the point where I have a selectable list of options, which are all loaded into the same .xib files. I am trying to make it so upon the click on a cell a different .xib file is populated below, and all of the other cells shift down. However, I am unsure of how to have 2 different xib's as TableViewCells in swift.
Upvotes: 0
Views: 3200
Reputation: 1153
There's two ways I can think of to accomplish what you are trying to do:
isExpanded
. When isExpanded
is set, your cell could unhide the options (by changing constraints).Multiple xibs: When tapped, you could insert a new item into your datasource. In your cellForRow, you could check for some identifier and load either the regular cell or the options cell using something like this:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == optionsRow {
let cell = tableView.dequeueReusableCell(withIdentifier: OptionsCellIdentifier, for: indexPath) as! OptionsCell
//Configure cell here
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: NormalCellIdentifier, for: indexPath) as! NormalCell
//Configure cell here
return cell
}
}
Upvotes: 1