uinavigationitem

iPhone: Setting Navigation Bar Title

。_饼干妹妹 提交于 2019-11-27 06:13:34
Hey all. I'm still pretty new to iPhone development, and I'm having a bit of trouble figuring out how to change the title of my Navigation Bar. On another question on this site somebody recommended using : viewController.title = @"title text"; but that isn't working for me...Do I need to add a UINavigationController to accomplish this? Or maybe just an outlet from my UIViewController subclass? If it helps, I defined the navigation bar in IB and I'm trying to set its title in my UIViewController subclass. This is another one of those simple things that gives me a headache. Putting self.title =

UINavigationItem titleView “ignored if leftBarButtonItem is set”?

时光总嘲笑我的痴心妄想 提交于 2019-11-27 05:56:29
问题 The documentation for UINavigationItem's titleView property says: "This property is ignored if leftBarButtonItem is not nil." However, I've set both the titleView and leftBarButtonItem properties in my testing and they both appear to show up fine. I've tested on all the simulators in my Xcode: 4.3, 5.0, and 5.1. Does anyone know if the documentation is just wrong, or is it correct on some older versions (e.g. 4.2, 3.x) that I haven't been able to test? 回答1: Check the documentation for

UIBarButtonItem with custom view not properly aligned on iOS 7 when used as left or right navigation bar items

試著忘記壹切 提交于 2019-11-27 05:56:20
The following code works up through iOS 6: UIButton *myButton = nil; myButton = [UIButton buttonWithType:UIButtonTypeCustom]; myButton.bounds = CGRectMake(0,0,44,30); // setup myButton's images, etc. UIBarButtonItem *item = nil; item = [[UIBarButtonItem alloc] initWithCustomView:customButton]; This is how the button is supposed to be aligned: However, on iOS 7, the button appears to be offset from the right or left by too many pixels: How can I get my custom bar button items to be aligned properly? malex Works until iOS11! You can use negative flexible spaces and rightBarButtonItems property

Add subtitle under the title in navigation bar controller in Xcode

笑着哭i 提交于 2019-11-27 05:08:50
问题 So I'm wanting to add a "subtitle" under the title in the navigation bar in navigation controller. Mostly everything I look up so far wants me to use CGRect. I don't know a whole lot what that is and it sounds like its wanting me to create an entire new view which is not what I am wanting to do. My question is, is there a dot method to adding a subtitle view easily? The closest thing I found was posted on stack overflow and here is the link: Create a subtitle in navigationbar Apparently last

How to change the UINavigationController back button name?

南笙酒味 提交于 2019-11-27 03:31:34
I have a UIViewController and I'm navigating from my first view controller to second view controller and I want to change the name of the button shown on the navigationcontroller for going back .... SecondViewController *secondController = [[SecondViewController alloc] initWithNibName:nil bundle:NULL]; [self.navigationController pushViewController:secondController animated:YES]; now in the second viewcontroller I want change the name of the button in the navigationController . In viewWillAppear write this self.navigationItem.title = @"List View"; And in ViewWilldisapper write this self

How to change text on a back button

北城以北 提交于 2019-11-27 02:39:27
By default the back button uses as a text on it a title of a viewcontroller. Can I change text on the back button without changing a title of a view controller? I need this because I have a view controller which title is too long to display and in this case I would like to display just "Back" as a caption for back button. I tried the following which didn't work: self.navigationItem.leftBarButtonItem.title = @"Back"; Thanks. Marc W Try self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil] autorelease]; I

Customize navigation bar with title view

大憨熊 提交于 2019-11-27 01:14:53
问题 I am trying to add a custom view in the center of a navigation bar and I am using the following code to test it: UIView * testView = [[UIView alloc] init]; [testView setBackgroundColor:[UIColor blackColor]]; testView.frame = CGRectMake(0, 0, 100, 35); [self.navigationController.navigationItem.titleView addSubview:testView]; I am setting this up in the viewDidLoad method of my view controller but when i run my program nothing seems to change in my navigation bar. Could you help me with this?

iphone - Custom UIBarButtonItem for back button

五迷三道 提交于 2019-11-27 01:11:41
问题 I am trying to use a custom item for the back button in my navigation bar. UIImage *backButtonImage = [UIImage imageNamed:@"backbutton.png"]; UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithImage:backButtonImage style:UIBarButtonItemStylePlain target:nil action:nil]; [self.navigationItem setBackBarButtonItem: customItem]; [customItem release]; What I end up getting is my image with a border around it. It looks like this (My image is the back button): How can I get rid of the

Show search bar in navigation bar without scrolling on iOS 11

淺唱寂寞╮ 提交于 2019-11-27 00:16:04
问题 I’m attaching a UISearchController to the navigationItem.searchController property of a UITableViewController on iOS 11. This works fine: I can use the nice iOS 11-style search bar. However, I’d like to make the search bar visible on launch. By default, the user has to scroll up in the table view to see the search bar. Does anyone know how is this is possible? Left: default situation after launch. Right: search bar made visible (by scrolling up). I’d like to have the search bar visible after

UINavigationBar multi-line title

江枫思渺然 提交于 2019-11-27 00:08:56
Is there a straightforward way of overriding the titleView of the current navigation bar item in a navigation bar within a navigation controller? I've tried creating a new UIView and replacing the titleView property of topView with my own UIVIew with no success. Basically, I want a multi-line title for the navigation bar title. Any suggestions? petert Set the titleView property of the UINavigationItem . For example, in the view controller's viewDidLoad method you could do something like: UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 480, 44)]; label.backgroundColor =