
当导航到某些模拟器和设备上的下一个视图控制器时,后退按钮标题是“后退”,并且在某些模拟器和设备上,后退按钮标题是第一个视图控制器的标题.
我真的很想明白为什么?
这不是更改后退按钮上的文本的问题.问题是在某些模拟器和设备上我看到了“后面”标题,在一些模拟器和设备上,我看到了前一个控制器的标题.
测试了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会自动显示Back标题. 要设置视图控制器的标题,请使用以下代码:
self.Title = @"<Title>";
我想你会从解释中得到这个.
总结以上是内存溢出为你收集整理的ios – UINavigationBar后退按钮在某些设备或模拟器上显示“Back”标题,在其他设备或模拟器上显示以前的视图控制器标题全部内容,希望文章能够帮你解决ios – UINavigationBar后退按钮在某些设备或模拟器上显示“Back”标题,在其他设备或模拟器上显示以前的视图控制器标题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)