uinavigationitem

NavigationItem setTitle doesn't work for second level UIViewController

牧云@^-^@ 提交于 2019-12-06 04:54:58
问题 in my app i have an UITabBarController with UINavigationControllers initialized like this UINavigationController *newsNavigationController = [[UINavigationController alloc] initWithRootViewController: newsViewControler]; newsViewController is an UIViewController. When i press the button in the tabbar to show the navigation item with the newsViewController the title in the navigation bar is set ok. in the newsViewController i have a method setup that i call after init. In the setup method i

IOS - Swift - adding target and action to BarButtonItem's customView

守給你的承諾、 提交于 2019-12-06 03:25:13
问题 I'm creating a custom view, with a uiimageview as a subview. I'm then using that custom view in my navigation bar as the rightBarButtonItem. This works to display the proper icon in the proper location, but for whatever reason the function I define in "action" is never being called, so the segue isn't performed when I tap on the rightBarButtonItem. Oddly enough if I do NOT insert a custom view, but instead comment that bit out and just set a title, target, and action for rightItem then the

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

ぐ巨炮叔叔 提交于 2019-12-06 03:06:16
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? this can be achieved using UIButton object of type .infoLight let infoButton = UIButton(type: .infoLight) infoButton.addTarget(self, action: #selector(infoButtonTapped), forControlEvents: .TouchUpInside) let barButton = UIBarButtonItem(customView: infoButton)

How do I set custom navigation bar(title + titleView) for all navigation controllers and view controller?

大憨熊 提交于 2019-12-06 00:10:42
I have a tabbed application with navigation controllers in tabs and view controller in them. All of them use the same navigation controller navigation bar: back button + logo image. Currently, I'm placing this code in every view controller: - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @"Back"; UIImage *headerImage = [UIImage imageNamed:@"Logo.png"]; self.navigationItem.titleView = [[[UIImageView alloc] initWithImage:headerImage] autorelease]; } IMHO it's not the best way to do that. I'm thinking about using a category for UIViewController and to override viewDidLoad

Wrong placement of search text field inside search bar on iOS 11

倖福魔咒の 提交于 2019-12-05 23:17:34
I am using UISearchController as part of navigation bar using the new APIs introduced in iOS 11. I am using it in the following manner in my ViewController's viewDidLoad - (void)viewDidLoad { [super viewDidLoad]; [_table setDataSource:self]; [_table setDelegate:self]; searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; [self.navigationItem setSearchController:searchController]; [self.navigationItem setHidesSearchBarWhenScrolling:NO]; [searchController.searchBar setBackgroundColor:[UIColor greenColor]]; } However, the search text field is rendered at the wrong

Large Navigation Bar Text With Multiple Colors

北慕城南 提交于 2019-12-05 03:39:36
iOS 11 introduces the option for larger text in the Navigation Bar. I would like to have a title that uses multiple colors. For example: It's fairly easy to set the title, and even to change the color of the entire title: [[self navigationItem] setTitle: @"Colors"]; [[[self navigationController] navigationBar] setLargeTitleTextAttributes: @{NSForegroundColorAttributeName: [UIColor colorFromHex: redColor]}]; What I can't figure out is how to change just part of the title. For example, a way to select the range like this – NSRangeMake(0, 1) – so that I could apply a color to it. This must be

How to change background color of UINavigationItem?

柔情痞子 提交于 2019-12-05 01:07:58
I have a UINavigationItem , but I can't found anything beside tittle, prompt, and back button in attribute inspector I wonder how can I change my UINavigationItem background color using code? or programmatically? You can change it through code... For Objective-C: self.navigationController.navigationBar.barTintColor = [UIColor redColor]; Write Above line in viewDidLoad method. For Swift: self.navigationController?.navigationBar.barStyle = UIBarStyle.BlackTranslucent self.navigationController?.navigationBar.barTintColor = UIColor.redColor(); OR self.navigationController!.navigationBar

How to create a UINavigationItem.TitleView based upon a nib file?

大憨熊 提交于 2019-12-04 21:57:42
I have a UINavigationController bassed sequence of screens. On one of the screens I want to replace the standard title with a custom TitleView. The custom view will be created with a nib file and will have an image and several labels. Do I create a UIViewController w/ associated nib file, load the nib, and assign the .view property to the TitleView? Basically, how do I use a nib where I can layout the necessary elements and then assign the resulting view to the TitleView property? Consider using UINib - it was exposed in iOS 4.0. It double perf since it caches the nib for you. UINib *nib =

hide and show left navigation bar button on demand in iOS-7

故事扮演 提交于 2019-12-04 21:20:53
问题 I added my left navigation bar button using the storyboard. but I want it to hide when I first load the screen. And then in response to something else, I want it to show. The navigation bar has a method for hiding the back button. But there is no method for hiding/showing the left button. Is there a simple way for doing this? Or do I have to use two methods: the hiding method creates an empty button and the showing method creates the correct button? The button in question is just the Add

How to Add UIImageView with UILabel in navigation bar of iphone?

烂漫一生 提交于 2019-12-04 19:33:17
I have some navigation bar in my UI of iphone app. Now i want to add two images on the navigation bar on center of the navigation bar.. I have successfully added the two UIImageView on the navigation-bar but my problem is that i have two UIImageView with the label on it .. Let me show u the snapshot ... now my problem is i don't know how to add this kind of label near UIImageView in navigation bar..so please if anyone can guide me for this then it will help me a lot.. i have already successfully inserted two images on navigation bar with this Code. UIImageView *Messageview = [[UIImageView