I'm trying to create a small app in iOS. After the Login Page, I have a TabBarController and the first tab in it is a TableViewController. In didSelectRowAtIndexPath I'm trying to push one view controller for every selected row. The same view controller but self.navigationController is (null) when I print it using an NSLog and I'm not able to push the ViewController. HELP!!
Here's the sample Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here, for example:
// Create the next view controller.
PlayerDetailsViewController *detailViewController = [[PlayerDetailsViewController alloc] initWithNibName:@"PlayerDetailsViewController" bundle:nil];
detailViewController.myImg.image=[UIImage imageNamed:[self.arrNames objectAtIndex:indexPath.row]];
detailViewController.name.text=[self.names objectAtIndex:indexPath.row];
detailViewController.year.text=[self.draft objectAtIndex:indexPath.row];
detailViewController.height.text=[self.height objectAtIndex:indexPath.row];
detailViewController.weight.text=[self.weight objectAtIndex:indexPath.row];
detailViewController.pro.text=[self.pro objectAtIndex:indexPath.row];
detailViewController.ppg.text=[self.ppg objectAtIndex:indexPath.row];
detailViewController.apg.text=[self.apg objectAtIndex:indexPath.row];
detailViewController.rpg.text=[self.rpg objectAtIndex:indexPath.row];
NSLog(@"%@",self.navigationController);
[self.navigationController pushViewController:detailViewController animated:YES];
}
UPDATE: I got the navigationController to work but now, the data in the pushed view(PlayerDetails) in blank!!
UINavigationController
on responder hierarchy. Set youUITabBarController
orTableViewController
as a rootViewController of UINavigationController. – Ryan