Changing the UIBackButtonItem title

前端 未结 14 911
终归单人心
终归单人心 2020-12-04 17:48

I have a navigationController-based app. I want to change the title of the back button for the root view controller. I have tried the following code in the rootViewControlle

14条回答
  •  难免孤独
    2020-12-04 18:48

    Maybe you don't wan't every pushed viewController from a viewController have a Cancel button than just set a leftBarButtonItem in the display viewController with a custom title

    self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"back", @"") style:UIBarButtonSystemItemCancel target:self action:@selector(popViewController)] autorelease];
    
    - (void)popViewController {
        [self.navigationController popViewControllerAnimated:YES];
    }
    

提交回复
热议问题