本文介绍了以编程方式向 UINavigationBar 添加后退按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码在我的应用中实现导航栏.(当我使用推送转场时,我的应用程序崩溃了,所以我需要一个模态转场,这意味着在调用模态转场后导航栏是隐藏的)
I am using the following code to achieve a navigation bar in my app. (my app was crashing when I used a push segue so I need a modal segue meaning the nav bar is hidden after the modal segue is called)
UINavigationBar *navbar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)]; //do something like background color, title, etc you self [self.view addSubview:navbar];有谁知道我可以通过上面的代码使用什么方法来实现导航栏中的后退按钮功能??
Does any one know any methods I can use with the above code to achieve back button functionality in the nav bar??
推荐答案使用下面的代码在左侧添加返回按钮
UINavigationBar *navbar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)]; //do something like background color, title, etc you self [self.view addSubview:navbar]; UINavigationItem *item = [[UINavigationItem alloc] init]; navbar.items= @[item]; UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(backBtnClicked:)]; item.leftBarButtonItem = backButton;更多推荐
以编程方式向 UINavigationBar 添加后退按钮?
发布评论