Reputation: 529
I am using this function but it is not working. I'm using StoryBoard and xcode 4.3.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
[tableView deselectRowAtIndexPath:indexPath animated:YES];
pushnavViewController *detailViewController = [[pushnavViewController alloc] initWithNibName:@"pushnavViewController" bundle:nil];
detailViewController.pushh.text = [listt objectAtIndex:indexPath.row];
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
}
Upvotes: 0
Views: 1309
Reputation: 230
1- Create story board Identifier: pushnavViewController Click on ViewController, choose tab identity inspector ==> Storyboard ID: pushnavViewController
2- Initiate UIViewController using Storyboard Identifier
UIStoryboard *mainStoryboard = self.storyboard;
UIViewController *mainViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"pushnavViewController"];
3- Push to another ViewController [self.navigationController pushViewController:mainViewController animated:YES];
Here is the code:
-(void) openABCPage
{
UIStoryboard *mainStoryboard = self.storyboard;
UIViewController *mainViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"pushnavViewController"];
[self.navigationController pushViewController:mainViewController animated:YES];
}
Upvotes: 0
Reputation: 529
here is the answer :
when you are using storyboard you have to use
pushnavViewController *detailViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"pushnavViewController"];
NOT
pushnavViewController *detailViewController = [[pushnavViewController alloc] initWithNibName:@"pushnavViewController" bundle:nil];
Also, do not forget to set the Identifier from storyborad .
Upvotes: 1
Reputation: 2742
I thought I'd take this out of the comments and have a stab at a solution. Sorry it's not a direct solution, but more of a suggestion...
Maybe the best thing to do is (if you're using Xcode 4.x) to create a new project selecting the 'Master-Detail Application' template. Look in the AppDelegate class and see how the MasterViewController is added as the root view controller of the UINavigationController there. See how this works and try to apply the same to your situation.
Also, look at the class reference for the UINavigationController.
Upvotes: 0