uinavigationitem

self.navigationItem.rightBarButtonItem vs self.navigationController.navigationItem.rightBarButtonItem

…衆ロ難τιáo~ 提交于 2019-12-10 19:57:59
问题 I'm somewhat confused about using self.navigationItem.rightBarButtonItem and self.navigationController.navigationItem.rightBarButtonItem . Which one is correct way? 回答1: The first, i.e. self.navigationItem.rightBarButtonItem . Every view controller has an associated navigation item. This is what is displayed in a navigation bar. So it's the current view controller's navigation item that you want to manipulate. If you manipulated the navigation controller's navigation item then that would show

UIActivityIndicatorView inside UINavigatorBar | Auto Layout still required after executing -layoutSubviews

隐身守侯 提交于 2019-12-10 19:33:33
问题 I would like to add an UIActivityIndicatorView (_av object) object into a left bar button item of UINavigationItem My code looks like : UIBarButtonItem * button = [[UIBarButtonItem alloc] initWithCustomView:_av]; [self.navigationItem setLeftBarButtonItem:button]; [button release]; but after I launch the code I take an error: *** Assertion failure in -[UINavigationBar layoutSublayersOfLayer:], /SourceCache/UIKit/UIKit-2380.17/UIView.m:5776 2013-04-15 16:28:39.246 * [12484:907] * Terminating

UINavigationItem: Add one more button

风格不统一 提交于 2019-12-10 17:57:53
问题 How can I add new button in navigationItem? Say I need to add it near right button. Code used for left right. self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_cancelButton]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_shareButton]; How can I add one more button? 回答1: There are Different Approach to add more then one Buttons on right side of navigationcontroller.one of the Simplist way is given below UIView

NavigationItem in Master/Detail application

三世轮回 提交于 2019-12-10 13:56:14
问题 I wrote a Master/Detail Application by using the Master/Detail template of XCode. After starting the app, the title of the navigation button for the master view is just "Master". Now I waant tio rename that button, but unfortunately I don't know how to access this button. In appdelegate.m there is the following code to initialize the views: MasterViewController *masterViewController = [[MasterViewController alloc] init]; UINavigationController *masterNavigationController = [

How to remove UINavigationbar prompt programmatically?

醉酒当歌 提交于 2019-12-10 13:17:56
问题 I have a view controller, and I set the navigation bar with prompt in IB. But I want to remove the prompt and make the bar as "1 line" sometimes. how can I do it in code? 回答1: [[self navigationItem] setPrompt: nil]; This animates the removal of the prompt. 来源: https://stackoverflow.com/questions/7049608/how-to-remove-uinavigationbar-prompt-programmatically

Navigation Controller Back button to go to the screen before the previous screen

左心房为你撑大大i 提交于 2019-12-10 13:09:34
问题 I'm wondering whether it's possible to go back to 2 previous page using navigation controller button. Right now, I've custom made the button using this code self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:mainLib.navCountryTitle style:UIBarButtonItemStyleBordered target:self action:@selector(handleBack:)]; And on 'handleback' method, I called this line [self.navigationController popViewControllerAnimated:YES]; So in this case it will go to the previous screen.

Back Navigation Button Not Showing up in Pushed View Controller

百般思念 提交于 2019-12-10 12:59:42
问题 I have a problem where I can successfully push a new view controller from my root view controller (using the Navigation-based application using Core Data template), but the detail view, which is a separate xib file from the root view controller, doesn't display the back navigation button. I'm certain that I've done all of the proper connections in IB, and everything else is working as expected. RootViewController.h @class ItemsViewController; @interface RootViewController :

UIAlertController moves leftBarButtonItem down

南笙酒味 提交于 2019-12-10 12:43:21
问题 I've created a UIAlertController with the preferred style of UIAlertControllerStyleAlert . The alert shows when the leftBarButtonItem is tapped. I created a UIBarButtonItem property called backButton and set the leftBarButtonItem = self.backButton . This is working as designed. I'm not using storyboards. The problem is that the leftBarButtonItem moves down (my guess: about 20pts) when the alert shows. Why is this happening? I know how to show/hide the button so the user can't see that the

Can you use UIAppearance to set the titleview of UINavigationItem?

时光怂恿深爱的人放手 提交于 2019-12-10 12:39:39
问题 I currently use this code to set the titleView of my navigation item: - (void)viewDidLoad { ... UIImage *navbarTitle = [UIImage imageNamed:@"navbartitleview1"]; UIImageView *imageView = [[UIImageView alloc]initWithImage:navbarTitle]; self.navigationItem.titleView =imageView; } Is there a way I could put this code using UIAppearance? [UINavigationItem appearance] is not valid. 回答1: No you wan't be able to do that with UIAppearence , what you can is to have a UIViewController from where all the

How to add a standard info button to a navigation bar in iOS?

对着背影说爱祢 提交于 2019-12-10 09:58:01
问题 I'd like to add a right bar button with the system's info icon to a navigation bar. But I see that UIBarButtonSystemItem does not provide such type of button. On the other hand, so I tried with a UIButton of type UIButtonType.infoLight , but I am not allowed to assign it to navigationItem.rightBarButtonItems . Is there any way to do this? 回答1: this can be achieved using UIButton object of type .infoLight let infoButton = UIButton(type: .infoLight) infoButton.addTarget(self, action: #selector