Yes, table programming is what the model-view-controller approach really suits. If you change the height of your cell somewhere like tableView:didDeselectRowAtIndexPath: you may feel that it works, but it doesnβt. What you can do in this method is to change your data and reload the table (or part of it).
As mentioned above, you must:
Specify the correct height for each cell in
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
Specify the correct view (cell) in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
When you want to make some changes, you must change your data in model (or the corresponding object containing your data related to the content), and then call one of the UITableView reload methods, perhaps:
- (void)reloadData - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
Apple's documentation can be scarce (although I think it's pretty professional): These will be the main links for you:
UITableView Class Reference
Link to UITableViewDataSource Protocol
Link to UITableViewDelegate Protocol
Table Programming Guide for iOS
source share