Add another button next to the “back” button on the left of a UINavigationBar

后端 未结 2 1703
余生分开走
余生分开走 2021-01-01 19:28

I\'ve tried this for hours but I still cannot solve it. When using UINavigationController and push a new view controller on top, I got a free \"back\" button on the left of

相关标签:
2条回答
  • 2021-01-01 20:12

    SWIFT 5 this worked for me. Thanks

    self.navigationItem.leftItemsSupplementBackButton = true
    
    0 讨论(0)
  • 2021-01-01 20:23

    As stated by steipete in the comment to the question, this is possible starting from iOS 5. You can use

    self.navigationItem.leftItemsSupplementBackButton = YES;
    

    and then you just need to add an UIBarButtonItem as leftButton to get a second button after the back button

    UIBarButtonItem *secondButton = [[UIBarButtonItem alloc] initWithTitle:@"Second" style:UIBarButtonItemStylePlain target:self action:@selector(yourAction)];
    self.navigationItem.leftBarButtonItem = secondButton;
    
    0 讨论(0)
提交回复
热议问题