uibarbuttonitem

Can I center a UIToolbar item?

可紊 提交于 2019-12-04 18:37:19
问题 I am putting a label on a UIToolbar (per this tip: Adding a UILabel to a UIToolbar). But the toolbar has a button on the left side, and so flexible spaces throw the label off the center, which is where I'd like it to be. Can I somehow center this toolbar item so that it remains centered in the toolbar? (Already tried balancing the button with a dummy fixed space, no dice.) Thanks! 回答1: Simplest way would be to put the label above the bar, in it's parent view, and justify it there. 回答2: Add a

Compose UIBarButtonItem changes position slightly when coming into view

空扰寡人 提交于 2019-12-04 18:12:35
问题 When presenting a new view with a UIBarButtonSystemItemCompose button in the navigation bar, the position is slightly off and adjusts after the view has come into view. I think this is a bug in iOS (version 8.3 used). It only happens when using the UIBarButtonSystemItemCompose. It does not happen with other types of Buttons (system, text or custom). The only code needed to replicate this bug is to use this ViewController code with the view that will come into view: #import "ViewController.h"

Hiding UIBarbuttonItem of navigationcontroller swift

六月ゝ 毕业季﹏ 提交于 2019-12-04 17:23:59
New to swift implemented sliding menu by learning from swrevealviewcontroller swift now i want to hide the menu button i.e. UIBarButtonItem which opens the side menu. I have searched found most of place following code: menuBtn.enabled = false but it only disables the button and not hide it. Please let me know what wrong i am doing here. If it's the left button : self.navigationItem.leftBarButtonItem.enabled = false; 来源: https://stackoverflow.com/questions/33103482/hiding-uibarbuttonitem-of-navigationcontroller-swift

How to put a badge on customized UIBarButtonItem

烈酒焚心 提交于 2019-12-04 16:51:20
问题 I have a navigation bar with two buttons, one is a back button the other a chat symbol. I write this code like this: UIBarButtonItem *_btn=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"back.png"] style:UIBarButtonItemStylePlain target:self action:@selector(goBackToPreviousView)]; self.navigationItem.leftBarButtonItem=_btn; self.navigationItem.leftBarButtonItem.tintColor = [UIColor blackColor]; UIBarButtonItem *_btn2=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@

UIBarButtonItem is disabled, but has normal color

浪子不回头ぞ 提交于 2019-12-04 16:28:03
问题 I'm having an issue with a UIBarButtonItem . I use the appearance proxy to set its color for states Normal and Disabled and I do this in the viewDidLoad method of the UIViewController . However, the button gets the Normal color, even when it is disabled (and it is definitely disabled because the IBAction method is not being called). The question is similar to this one text color of disabled uibarbuttonitem is always the color of the normal state, however, the solution posted here does not

Auto Layout iOS 11 Toolbar UIBarButtonItem with customView

谁说胖子不能爱 提交于 2019-12-04 15:52:39
Recently in our project there was a problem with a UIBarButtonItem that was using a customView. Before iOS 11 we did the layout via flexible spacing items. This didn't work anymore and so nothing was displayed. Because I didn't find an answer here on SO that really solved the issue for me, I looked into it and came up with a (admittedly kind of hacky) solution I wanted to share with you. Maybe it can help you or you have some feedback. This is mixed objc and swift code, hope you don't mind. As shown in the WWDC Video Updating Your App for iOS 11 : "And so now in iOS 11, UI toolbar and UI

How to change the icon of a Bar Button when pressed in Swift?

末鹿安然 提交于 2019-12-04 15:37:40
问题 I'm creating a stopwatch in Swift and I want to change the play icon I have selected for a bar button to a pause icon when the button is pressed to start the stopwatch. How do you do this? 回答1: For Swift 3 This is how I did it in Swift 3: var favoritesBarButtonOn: UIBarButtonItem! var favoritesBarButtonOFF: UIBarButtonItem! favoritesBarButtonOn = UIBarButtonItem(image: #imageLiteral(resourceName: "TabBarIconSettingsOff"), style: .plain, target: self, action: #selector

Removing right bar button item from navigation item

ぐ巨炮叔叔 提交于 2019-12-04 15:30:34
问题 I have added a right bar button item in my navigation item and want to remove this on some condition. This is what I am doing: self.navigationItem.rightBarButtonItem = nil; But not getting the desired behavior. I want to hide it but do not find any method for it. 回答1: What you're doing should work. I've done that lots of times. Are you sure you're removing the button from the correct navigation item? Is self the currently displayed UIViewController ? 回答2: i know three ways: (supossing in

Add navigation bar on a view controller

自闭症网瘾萝莉.ら 提交于 2019-12-04 15:11:30
问题 i am new on iOS and i wanna add a navigation bar on my view controller with 2 buttons back on left and subscribe on right. ive got no clue how to do it..till now i have just added a nav bar from interface builder, created a (strong)refrnce for it in .h file and did following coding. navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 20, 1026, 50)]; [navBar setTintColor:[UIColor clearColor]]; [navBar setBackgroundColor:[UIColor redColor]]; [navBar setDelegate:self]; [self.view

How to detect when MKUserTrackingBarButtonItem is used

两盒软妹~` 提交于 2019-12-04 08:05:31
I'm currently trying to find a way to detect when the MKUserTrackingBarButtonItem is used, other than deal with the mapView:didUpdateUserLocation: delegate method. I tried to setAction of the MKUserTrackingBarButtonItem to call my function (check this thread ), but of curse it removes the updating location action, which I don't want. I don't find any delegate method triggered :/ Thanks for any idea. If your MKUserTrackingBarButtonItem has been assigned a MKMapView to operate on then the map view's delegate will receive mapView:didChangeUserTrackingMode:animated: when the tracking mode is