uinavigationitem

Restoring navigationItem.title after removing navigationItem.titleView

末鹿安然 提交于 2019-12-21 09:15:21
问题 My App has 2 tabs ( tabA and tabB ), based on location the I set the navigationItem.titleView of tabB to a UIImageView when - viewWillAppear: is called. The default behaviour of tabB is to simply display a title, e.g: The issue is when the location changes and I remove the UIImageView navigationItem.titleView (using - removeFromSuperview ), the default title has also disappeared and trying to set it with: self.navigationItem.title = @"TITLE"; Does not work. Any ideas on how to solve this? 回答1

backBarButtonItem gets renamed in iOS 7 when there is a long title

☆樱花仙子☆ 提交于 2019-12-21 09:15:05
问题 One behavior I observed in iOS 7 is that the title of the backBarButtonItem of a UINavigationItem get's renamed if the title of the currently displayed view controller is too long. Too lazy to explain so here are some photos: As you can see, when the title is too long, the back button gets renamed to "Back" regardless of what it was previously. If the title is even longer, the back button doesn't show any text, just the left arrow image. Does anyone know how to disable this behavior? I would

navigation bar right bar button items spacing

只愿长相守 提交于 2019-12-20 08:58:08
问题 I have created a with left bar button item added from storyboard, titleView and three right bar button items from code. Here is the code: override func viewDidLoad() { super.viewDidLoad() var screenWidth = UIScreen.mainScreen().bounds.width // custom title view var navBarWidth: CGFloat = self.navigationController!.navigationBar.frame.size.width let customTitleView = UIView(frame: CGRectMake(0, 0, navBarWidth, 44)) titleLabel = UILabel(frame: CGRectMake(20, 0, navBarWidth, 40)) titleLabel.text

Adding multiple custom bar buttons to custom nav bar

筅森魡賤 提交于 2019-12-20 07:16:49
问题 I need to add two bar button items to each end of my custom navigation bar in Swift. I'm using the following method, and although I get no errors, nothing at all is appearing. I'm using my own custom icons, which do appear when I add them using interface builder. Obviously, I can only add one to each end that way. @IBOutlet weak var navBar: UINavigationBar! override func viewDidLoad() { var iconOne = UIImage(named: "iconOne") var iconTwo = UIImage(named: "iconTwo") var buttonOne

Custom background for UINavigationBar problems

有些话、适合烂在心里 提交于 2019-12-18 12:03:40
问题 I've managed to add a custom background to my navigation bar by using: UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"UINavigationBar.png"]]; [myViewController.navigationBar insertSubview:iv atIndex:0]; [iv release]; This works fine and I can see the title and buttons okay. However, when I drill down one level and then go back to the root, the buttons are hidden, but the title is still visible. It appears the navigation bar image is covering the button items. I'm

How can I get a full-sized UINavigationBar titleView

雨燕双飞 提交于 2019-12-18 11:07:08
问题 I am trying to add a custom control as the titleView in a UINavigationBar. When I do so, despite setting the frame and the properties that would normally assume full width, I get this: The bright blue can be ignored as it is where I am hiding my custom control. The issue is the narrow strips of navbar at the ends of the bar. How can I get rid of these so my customview will stretch 100%? CGRect frame = CGRectMake(self.view.bounds.origin.x, self.view.bounds.origin.y, self.view.width,

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

不羁的心 提交于 2019-12-17 08:02:42
问题 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

How to change the UINavigationController back button name?

♀尐吖头ヾ 提交于 2019-12-17 07:14:38
问题 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 . 回答1: In

How to enable back/left swipe gesture in UINavigationController after setting leftBarButtonItem?

回眸只為那壹抹淺笑 提交于 2019-12-17 07:10:29
问题 I got the opposite issue from here. By default in iOS7 , back swipe gesture of UINavigationController 's stack could pop the presented ViewController . Now I just uniformed all the self.navigationItem.leftBarButtonItem style for all the ViewControllers . Here is the code: self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:LOADIMAGE(@"back_button") style:UIBarButtonItemStylePlain target:self action:@selector(popCurrentViewController)]; after that, the

How to change text on a back button

别说谁变了你拦得住时间么 提交于 2019-12-17 07:01:38
问题 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. 回答1: Try self.navigationItem.backBarButtonItem = [[[UIBarButtonItem