Click on button to change to table view in Objective-c
I have two button in my program(figure A), I开发者_如何学编程 want to change to a table view(figure B) when I click on one button. Can someone please advise how to do that?
Thanks
Quite simple actually. In the button's handler method, create the table view controller and display it modally or push it on the navigation stack.
[myButton addTarget:self action:@selector(displayTableView:) forControlEvents:UIControlEventTouchUpInside];
-(void)displayTableView:(id)sender
{
MyTableViewController* myTVC = [[MyTableViewController alloc] initWithNibName:@"myTVC" bundle:nil];
[self.navigationController presentModalViewController:myTVC animated:YES];
//[self.navigationController pushViewController:myTVC animated:YES]; //2nd option
[myTVC release];
}
精彩评论