So we got a Nav Controller with a UITableView for the RootViewController. Then when the user clicks the table cell, we push an EKEventController onto the Nav stack and display details for the event represented by the table cell.
I am trying to add a button on the right side, but it does not show up.
I’m adding the button when the user clicks the table cell.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Upon selecting an event, create an EKEventViewController to display the event.
self.detailViewController = [[[EKEventViewController alloc] initWithNibName:nil bundle:nil]autorelease];
detailViewController.event = [self.eventsList objectAtIndex:indexPath.row];
detailViewController.allowsEditing = NO;
UIBarButtonItem *locationMapViewButtonItem = [[UIBarButtonItem alloc]
initWithTitle:@"Map"
style:UIBarButtonItemStylePlain
target:self
action:@selector(showMap:)];
self.navigationItem.rightBarButtonItem = locationMapViewButtonItem;
[locationMapViewButtonItem release];
UITableView *eventTableView = [[self.detailViewController.view subviews]objectAtIndex:0];
[self.navigationController pushViewController:detailViewController animated:YES];
}
The right bar button disappears when the EKEvent controller shows up however.
You need to set the navigation item of the view controller being pushed, so your line:
Should become: