uibarbuttonitem

UIToolbar and Flexable/Fixed bar button items

好久不见. 提交于 2019-12-24 02:18:17
问题 I have a toolbar, where I want to have one UIBarButtonItem centered and have another on the very right. However when I add the button on the right, my centered button gets shifted further to the left (see attached). I can't figure out how to get this resolved without using code (I would like to use interface builder only). Any ideas? 回答1: To do this in just IB, add a fixed bar button item to the very left of the bar that's the exact same width of the 'switch camera' button, followed by a

leftBarButtonItem setTitleTextAttributes issue in iOS11

為{幸葍}努か 提交于 2019-12-24 00:46:21
问题 I have an app with a deployment target of iOS 9.3. I have just upgraded to Xcode 9.0.1, and have noticed this issue across all simulator devices and my own iPhone7 device running iOS11. The issue does not impact devices running < iOS11. I am initialising a left bar button item, with a custom font as follows (in viewDidLoad): UIBarButtonItem *safeModeButton = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:@selector(toggleSafeMode)];

UIBarButtonItemStyleDone does not create blue buttons in navigation bar when controller is pushed

我们两清 提交于 2019-12-23 08:51:20
问题 I've searched around on several different forums and can't seem to find an answer for this. I have added a bar button item to a navigation controller and set its style to UIBarButtonItemStyleDone. When this is the first controller on the navigation stack, the button properly shows up blue. However, when the controller is created and pushed onto the stack, the style is ignored and it shows up black. I know that this problem occurs when the tintColor has been changed, but I am using the

UIBarButtonItem, set exclusive touch

廉价感情. 提交于 2019-12-23 08:36:11
问题 Is there a way to make UIBarButtonItem exclusive touch? At the moment you can select multiple at the same time and it keeps crashing my application. 回答1: Slightly easier method than subclassing the navbar but the same idea; for(UIView *temp in self.navigationController.navigationBar.subviews) { [temp setExclusiveTouch:YES]; } Put this just after you add your bar button items. 回答2: I managed this problem by subclassing UINavigationBar and overriding layoutSubviews method. Something like this:

leftbarbuttonitem does not show up in the navigation bar

旧街凉风 提交于 2019-12-23 07:37:05
问题 I've been developing an iOS app and have been having issues with using an image as the left bar button item in the navigation bar. I have attempted this in the following ways: UIImage *backButtonImage = [UIImage imageNamed:@"backbuttonCB"]; CGRect buttonFrame = CGRectMake(0, 0, backButtonImage.size.width, backButtonImage.size.height); UIButton *backButton = [[UIButton alloc] initWithFrame:buttonFrame]; [backButton setImage:backButtonImage forState:UIControlStateNormal]; UIBarButtonItem

How to restrict rightBarButtonItem size in UINavigationBar?

拥有回忆 提交于 2019-12-23 03:26:28
问题 I create a rightBarButtonItem with this method : - (UIBarButtonItem *)customBarButtonWithSelector:(SEL)callback { UIButton *customButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; customButton.bounds = CGRectMake(0, 0, 30.0f, 30.0f); return [[[UIBarButtonItem alloc] initWithCustomView:customButton] autorelease]; } At execution time the selector is fired when the bar is touched outside the button (near the middle). Is there a way to restrict the event responder in the defined bounds

adding icon between back button & title of navigation bar

最后都变了- 提交于 2019-12-23 03:14:20
问题 I want to put an icon by side of the title of my navigation bar. I'd prefer not to implement it as a custom titleView, because then i'll need to create a custom titleView for each controller i put on the stack (and I have pretty deep nesting). I'm adding currently as an UIImageView to a navigationBar. My problem is to calculate exactly this icon's horizontal position. It depends on the width of the back button, which has each time another title. How do I calculate this back button frame?

How can a disabled button get touches?

谁说胖子不能爱 提交于 2019-12-22 23:14:25
问题 I was just wondering how can this happen. In my iPhone application during a http request loading I am disabling a button in the navigation bar. But when I touch the button three or four times the action method gets called after the loading is completed this means that even though the button is disabled the touches are detected on it and later the ibaction method is called . So is this exceptional or is there any way to prevent this ? Thanks .... 回答1: Setting a UIControl disabled does not

How can a disabled button get touches?

╄→尐↘猪︶ㄣ 提交于 2019-12-22 23:11:12
问题 I was just wondering how can this happen. In my iPhone application during a http request loading I am disabling a button in the navigation bar. But when I touch the button three or four times the action method gets called after the loading is completed this means that even though the button is disabled the touches are detected on it and later the ibaction method is called . So is this exceptional or is there any way to prevent this ? Thanks .... 回答1: Setting a UIControl disabled does not

How to show/hide a search bar inside a navigation bar (iOS 8) as in Apple's Calendar app?

孤街浪徒 提交于 2019-12-22 17:49:03
问题 How to implement: I have UIBarButtonItem with a search icon, after I click on it, I want to show the search bar in navigation bar and on click cancel button in search bar, I want to show navigation bar without search and with buttons and title like in IOS 7 calendar app. 回答1: Setup an action for your search button to present a UISearchController . See the Search > Present Over Navigation Bar demo in Apple's UICatalog sample code: - (IBAction)searchButtonClicked:(UIBarButtonItem *)sender { //