大佬教程收集整理的这篇文章主要介绍了ios – UINavigationBar后退按钮在某些设备或模拟器上显示“Back”标题,在其他设备或模拟器上显示以前的视图控制器标题,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我真的很想明白为什么?
这不是更改后退按钮上的文本的问题.问题是在某些模拟器和设备上我看到了“后面”标题,在一些模拟器和设备上,我看到了前一个控制器的标题.
测试了20多个模拟器和设备.
这是代码:
App代表
#import "AppDelegate.h" #import "FirstViewController.h" #import "SecondViewController.h" @interface AppDelegate () @property (nonatomic,strong) UINavigationController *navigationController; @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:nil bundle:nil]; self.navigationController = [[UINavigationController alloc] initWithRootViewController:firstViewController]; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]]; self.window.rootViewController = self.navigationController; self.window.BACkgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; }
第一视图控制器
#import "FirstViewController.h" #import "SecondViewController.h" @interface FirstViewController () @property (nonatomic,strong) UIButton *btnDisplaySecondViewController; @end @implementation FirstViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundLeorNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundLeorNil]; if (self) { // Custom initialization } return self; } -(void)performDisplaySecondViewController:(id)paramSender{ SecondViewController *secondControllrt = [[SecondViewController alloc] initWithNibName:nil bundle:nil]; [self.navigationController pushViewController:secondControllrt animated:YES]; } - (void)viewDidLoad { [super viewDidLoad]; self.title = @"First Controller"; self.btnDisplaySecondViewController = [UIButton buttonWithType:UIButtonTypeSystem]; [self.btnDisplaySecondViewController settitle:@"Display Seconf View Controller" forState:UIControlStateNormal]; [self.btnDisplaySecondViewController sizeToFit]; self.btnDisplaySecondViewController.center = self.view.center; [self.btnDisplaySecondViewController addTarget:self action:@SELEctor(performDisplaySecondViewController:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:self.btnDisplaySecondViewController]; UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0,0.0,100.0f,40.0f)]; imageView.contentMode = UIViewContentModeScaleAspectFit; UIImage *image = [UIImage imagenamed:@"ios7_0135"]; [imageView setImage:image]; self.navigationItem.titleView = imageView; }
第二视图控制器
#import "SecondViewController.h" @interface SecondViewController () @end @implementation SecondViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundLeorNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundLeorNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; self.title = @"Second Controller"; }
以上是大佬教程为你收集整理的ios – UINavigationBar后退按钮在某些设备或模拟器上显示“Back”标题,在其他设备或模拟器上显示以前的视图控制器标题全部内容,希望文章能够帮你解决ios – UINavigationBar后退按钮在某些设备或模拟器上显示“Back”标题,在其他设备或模拟器上显示以前的视图控制器标题所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。