create drop down in UITableView swift -
i have gotten point have selectable list of options, loaded same .xib files. trying make upon click on cell different .xib file populated below, , of other cells shift down. however, unsure of how have 2 different xib's tableviewcells in swift.
there's 2 ways can think of accomplish trying do:
- single xib file: should use single xib file hides lower section contains options until cell tapped. when tapped, property on uitablecell class set, e.g.
isexpanded. whenisexpandedset, cell unhide options (by changing constraints). multiple xibs: when tapped, insert new item datasource. in cellforrow, check identifier , load either regular cell or options cell using 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 }}
wiki

Comments
Post a Comment