Adding back button to navigation bar

后端 未结 3 1207
终归单人心
终归单人心 2020-12-03 09:02

I\'ve added a navigation bar to a UIViewController. It is displayed from another UIViewController only. I\'d like to have a left side back button that is shaped similar to

3条回答
  •  情深已故
    2020-12-03 09:22

    If you're using a navigation controller:

    MyViewController *_myViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
    [[self navigationController] pushViewController:_myViewController animated:YES];
    UIBarButtonItem *_backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleDone target:nil action:nil];
    self.navigationItem.backBarButtonItem = _backButton;
    [_backButton release], _backButton = nil;
    [_myViewController release], _myViewController = nil;
    

    If you're not using a navigation controller, look into the Three20 style components to make custom bar buttons.

提交回复
热议问题