屏幕导航 iPhone,xcode?
我有 3 个屏幕 使用
- (void)viewDidLoad { 将标题设置为 screen1 [超级viewDidLoad]; self.navigationItem.title =@"产品"; }
当导航到下一个屏幕 (screen2) 时,第二个屏幕的标题为“类别” 但顶部有一个按钮名称为“产品”到 Screen1
我想将按钮名称更改为“返回”
请告诉我如何操作?
尝试self.navigationItem.leftBarButtonItem .title = @"Back";
i'm having 3 screens
set title to screen1 using
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title =@"Products";
}
when navigation to next screen (screen2) second screen having the title "Categories"
but there is a button on the top name "Products" to Screen1
i want to change the button name as "Back"
Please tell me how?
triedself.navigationItem.leftBarButtonItem .title = @"Back";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请参阅这两个:
如何设置UINavigationBar 上后退按钮的文本?
如何更改导航栏上“后退”按钮的标题
解决您的问题。
See these two:
How to set the text of a back button on a UINavigationBar?
How do I change the title of the "back" button on a Navigation Bar
Solves your problem.
UIBarButtonItem *item=self.navigationItem.leftBarButtonItem;
item=[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:nil action:nil];
self.navigationItem.backBarButtonItem=项目;
[物品发布];
将此代码按原样放入您的第一个屏幕 viewDidLoad 方法中,它确实有效。
UIBarButtonItem *item=self.navigationItem.leftBarButtonItem;
item=[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:nil action:nil];
self.navigationItem.backBarButtonItem=item;
[item release];
Put this code in your first scree viewDidLoad method as it is It really works.
您必须执行类似以下操作,才能将后栏按钮的文本设置为除前一个视图名称之外的其他内容:
您不能执行以下操作:
这会将堆栈上的前一个视图设置为“您的标题”,而不是那是以前。
You have to do something like the follows to set the text of the back bar button to something other than what the previous view was named:
You CANNOT do the following:
This sets the previous view on the stack to "Your Title" and not was it was before.