I wanna add a UITableView to UITableViewCell dynamically, when i click on the UITableViewCell, it will change it’s height and display a UITableView inside it, and when i click on the UITableViewCell again, it will hide the UITableView.
To do that, i did the following:
- Create a custom
UITableViewCellwith a nib file. - Load it to the main
UITableViewwith adjusting the information i wanna display it before expanding it. - Implement the
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPathto handel the selectedUITableViewCell. - Initiate the second
UITableView(it’s aUITableViewController, created it with a nib file), resize the selectedUITableViewCellto fit the new size (expand it’s size). - Adding the
UITableViewusing[selectedCell.contentView addSubview:desc.view]; - Reload the main
UITableView.
BUT, it didn’t work, all i’ve got is an empty space with a correct size. i’ve used [tableView addSubview:desc.view]; but it’s add the UITableView inside the main UITableView, not inside the selected cell.
Note: the added UITableView is not scrollable and when i click on one of it’s cell it will navigate me to another view.
Any hint will be appreciated.
thx in advance.
Like sosborn said, i used a
UITableViewinstead ofUITableViewControllerand added the new table view in- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPathcause i was calling the
[tableView reloadData]every time the user select a cell.