How to show back button on the RootViewController of the UINavigationController?

前端 未结 4 660
独厮守ぢ
独厮守ぢ 2021-01-08 01:29

Here is my code. I want to put a back button on the opening rootviewController.

- (void)selectSurah:(id)sender {

    SurahTableViewController * surahTableVi         


        
4条回答
  •  北海茫月
    2021-01-08 01:52

    I don't believe it's possible to pop the root view controller off the navigation stack, but you can fake it with a UIButton added as the custom view of a UIBarButtonItem:

    UIButton *b = [[UIButton alloc]initWithButtonType:UIButtonTypeCustom];
    [b setImage:[UIImage imageNamed:@"BackImage.png"] forState:UIControlStateNormal];
    [b addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
    self.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:b];
    

    A suitable PSD of iOS UI elements can be found here.

提交回复
热议问题