uibarbuttonitem

iPad's UIActionSheet showing multiple times

梦想与她 提交于 2019-12-03 11:55:22
I have a method called -showMoreTools: which is: - (IBAction) showMoreTools:(id)sender { UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:@"Close" otherButtonTitles:@"Add Bookmark", @"Add to Home Screen", @"Print", @"Share", nil]; popupQuery.actionSheetStyle = UIActionSheetStyleDefault; popupQuery.dismiss [popupQuery showFromBarButtonItem:moreTools animated:YES]; [popupQuery release]; } When an user taps a UIBarButtonItem it displays that UIActionSheet , but then, if the user wants to close the UIActionSheet without

Can I center a UIToolbar item?

℡╲_俬逩灬. 提交于 2019-12-03 11:43:23
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! Simplest way would be to put the label above the bar, in it's parent view, and justify it there. Add a flexible space item to the left and right of your center item, like you did. Then add a fixed space item at the

UIBarButtonItem is disabled, but has normal color

坚强是说给别人听的谎言 提交于 2019-12-03 11:25:58
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 work for me. My app is for iOS 8.2 and I'm using Xcode 6.2 Any ideas? EDIT : I am not sure if this is

Compose UIBarButtonItem changes position slightly when coming into view

你离开我真会死。 提交于 2019-12-03 11:02:14
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" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super

How to put a badge on customized UIBarButtonItem

荒凉一梦 提交于 2019-12-03 10:55:25
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:@"chat.png"] style:UIBarButtonItemStylePlain target:self action:@selector(startChat)]; self.navigationItem

Add spacing between UIToolbar

巧了我就是萌 提交于 2019-12-03 09:58:48
I have a toolbar that looks like the following: The issue is that it is kind of cluttered and therefore I would like to add some spacing to it. I tried doing: UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; self.toolbar_array = [[NSMutableArray alloc] initWithObjects:self.mention, spacer, self.picture, spacer, share, spacer, self.message, nil]; But it still gives me the same thing. How can I add a 10px between these UIBarButtonItems ? Joe UIBarButtonItem *fixedSpace = [[UIBarButtonItem alloc]

Removing right bar button item from navigation item

醉酒当歌 提交于 2019-12-03 09:36:17
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. 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 ? i know three ways: (supossing in right side) if you have more than one bar button: self.navigationItem.rightBarButtonItems = nil else if you have only

Add navigation bar on a view controller

丶灬走出姿态 提交于 2019-12-03 08:57:00
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 addSubview:navBar]; UIBarButtonItem *bi1 = [[UIBarButtonItem alloc] initWithTitle:@"subscribe" style

How do you set the font size on a UIBarButtonItem?

拟墨画扇 提交于 2019-12-03 08:11:04
问题 I can't find a way to set the font size of the title in a custom UIBarButtonItem. The only way I can think of getting around this is to set it as an image which I would like to avoid. Any other suggestions? 回答1: In a easy way, simply: Objective-C: NSUInteger fontSize = 20; UIFont *font = [UIFont boldSystemFontOfSize:fontSize]; NSDictionary *attributes = @{NSFontAttributeName: font}; UIBarButtonItem *item = [[UIBarButtonItem alloc] init]; [item setTitle:@"Some Text"]; [item

Smaller active area for custom UIBarButtonItem

狂风中的少年 提交于 2019-12-03 07:59:01
I have a UINavigationBar with a custom UIBarButtonItem (which uses a UIButton as its custom view). The problem is: the active area of the custom button is much too large, if I tap at least 40 pixels outside the button, it still gets registered as a tap on the button. This results in accidental taps. How can I reduce the active area on these buttons? I noticed this weirdness too. I found that using a container UIView fixes this. For example: UIButton *menuButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)]; [menuButton addTarget:self action:@selector(revealMenu:) forControlEvents