Domanda

I have a simple app where I push views to the navigation. However, on one of the screens I push tab controller with two tabs. When I do this the navigation goes away when I reach the tab controller screen. On the navigation of the tab screens I would like to know how a < Back button.

Basically, I want to know how to manually create a < Back button on top left

È stato utile?

Soluzione

Try this:

UIBarButtonItem *backBarButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon_back.png"] style:UIBarButtonItemStylePlain target:self action:@selector(goBack:)];
self.navigationItem.leftBarButtonItem = backBarButton;

Then write the goBack method:

- (void)goBack:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

Note: There are some other initializer for UIBarButtonItem. Choose any one as your need.

Hope this helps.. :)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top