I want to make a table view inside of a table view. I mean how can I make an app that clicking a cell goes to another list of cells to click to go subclass?
+1
A:
I don't know what you mean by a table view inside of a table view, I think what you want to do is have a hierarchy of table views. You can push another table view onto the stack within the delegate method didSelectRowAtIndexPath
.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
MySecondViewController *secondController = [[MySecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:secondController animated:YES];
}
By implementing this method when you click a cell, it goes to another table view (list of cells).
Convolution
2010-01-22 17:23:45
Memory leak in your code, see my answer.
St3fan
2010-01-22 18:13:48
Thanks, I was hoping he knew about releasing objects, but this is now perfect copy and paste code.
Convolution
2010-01-22 18:32:43
+1
A:
Convolution's answer contains a memory leak. Proper code should look like this:
MySecondViewController *secondController = [[MySecondViewController alloc]
initWithNibName: @"SecondViewController" bundle: nil];
if (secondController != nil) {
[self.navigationController pushViewController: secondController animated: YES];
[secondController release];
}
The release
is essential. Otherwise you leak memory.
St3fan
2010-01-22 18:13:32