uibarbuttonitem

How to fire uibarbuttonitem click event programmatically

a 夏天 提交于 2019-11-27 19:28:24
I have created a UIActionSheet UIActionSheet * action = [[UIActionSheet alloc]initWithTitle:@"" delegate:self cancelButtonTitle: @"cancel" destructiveButtonTitle: @"OK" otherButtonTitles: nil]; [action showInView:self.view]; [action release]; On the event of the cancel button in the UIActionSheet I want to fire the event of a UIBarButtonItem , which is in my view. My question is how can I fire the button event(without touching the button) in the UIActionSheet delegate method ayoy Not knowing the current bar button item action you can invoke it this way: [barButtonItem.target performSelector

Make a custom back button for UINavigationController

白昼怎懂夜的黑 提交于 2019-11-27 19:01:10
问题 I'm developping an app for iOS 4.2+. I subclassed my UINavigationController to insert two UIImageView and make the navigation bar look custom. Everything is working great but I have a little problem. I created custom UIBarButtonItem and inside my view controllers i put them with : self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backButton]; It works too but the problem is that to make this work I need to call it from: - (void)viewDidAppear:(BOOL)animated ;

How do you add more than one UIBarButton on UINavigationItem.rightBarButtonItem (or leftBarButtonItem)?

為{幸葍}努か 提交于 2019-11-27 18:24:50
I have tried this approach/hack: http://blog.blackwhale.at/2009/06/uibuttons-in-uinavigationbar/ The problem is this leaves a faint seam. I tried setting the background image of the nested toolbar to an image I captured of what it should be. That didn't work. The image was not applied. I have also tried using a nested UINavigationBar and that didn't seem to work. I have seen this done in several iPhone apps. Does anyone know how? [EDIT] I want the buttons to look like normal UIBarButtonItems and be able to use system styles like UIBarButtonSystemItemAdd, UIBarButtonSystemItemRefresh. The link

How can we put two line in UIBarButtonItem in Navigation Bar

。_饼干妹妹 提交于 2019-11-27 18:09:10
问题 "Now Playing" is in One line in UIBarButtonItem. I have to put it in two lines, like "Now" is ay top and "Playing" is at bottom.I have written the following line of code:- UIBarButtonItem *flipButton = [[UIBarButtonItem alloc] initWithTitle:@"Now Playing" style:UIBarButtonItemStyleBordered target:self action:@selector(flipView)]; self.navigationItem.rightBarButtonItem = flipButton; So i want to pu line break in between "Now Playing". So please help me out. 回答1: Yes you can. It is fairly

Change font of back navigation bar button

你离开我真会死。 提交于 2019-11-27 18:06:44
I want to be able to set the font of my apps navigation bar back button without doing anything too crazy and without losing any other design characteristics of the button (i.e. I want to keep the arrow). Right now I use this in viewDidAppear: to set the font of the normal bar button items. for (NSObject *view in self.navigationController.navigationBar.subviews) { if ([view isKindOfClass:[UIButton class]]) { [((UIButton*)view).titleLabel setFont:[UIFont fontWithName:@"Gill Sans" size:14.0]]; } } However this makes no change on the back button, regardless of which UIViewController this code is

Add button to navigationbar programmatically

ぐ巨炮叔叔 提交于 2019-11-27 17:28:58
Hi I need to set the button on right side, in navigation bar, programatically , so that if I press the button I will perform some actions. I have created the navigation bar, programatically by; navBar=[[UINavigationBar alloc]initWithFrame:CGRectMake(0,0,320,44) ]; Similarly, I need to add the button, on the right side of this navigation bar. For that I used, 1. UIView* container = [[UIView alloc] init]; // create a button and add it to the container UIButton* button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 130, 44.01)]; [container addSubview:button]; [button release]; // add another

Custom background/transparent background on UIBarButtonItem?

半城伤御伤魂 提交于 2019-11-27 16:18:14
问题 How is this effect achieved? Code snippets are highly welcome. This can be seen in Notes app and other apps on the App Store. It seem that either the buttons on the navigation controller are transparent and show the custom background of the navigation controller or that they themselves have a custom background applied to them. Any ideas on how this is achieved? EDIT: Here is an example from the iBooks app for the iPhone. As you can see, not only the UIButtons, but also the segmented control

Navigation bar with multiple buttons

故事扮演 提交于 2019-11-27 15:44:00
问题 I have a navigation bar with a left and right button, and I need to put another button next to the right button. Does anyone know how I can go about this? Here is some code to help: - (id)init { self = [super initWithStyle:UITableViewStyleGrouped]; if (self) { _pinArray = [[NSArray alloc]init]; _pinArray = [Data singleton].annotations; UIBarButtonItem *right = [[UIBarButtonItem alloc]initWithTitle:@"Map" style:UIBarButtonItemStylePlain target:self action:@selector(goToMap:)]; self

Custom UIBarButtonItems from UIButtons with custom images - is it possible to make the tap targets larger?

限于喜欢 提交于 2019-11-27 14:45:10
问题 I'm making UIBarButtons as follows: // Create "back" UIBarButtonItem UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; backButton.frame = CGRectMake(0, 0, 28, 17); [backButton addTarget:self action:@selector(backButtonTapped) forControlEvents:UIControlEventTouchUpInside]; backButton.showsTouchWhenHighlighted = YES; UIImage *backButtonImage = [UIImage imageNamed:@"back-button.png"]; [backButton setBackgroundImage:backButtonImage forState:UIControlStateNormal];

setting image for UIBarButtonItem - image stretched

纵然是瞬间 提交于 2019-11-27 14:36:18
When I try to use UIBarButtonItem's "initWithImage" to initialize a navigation bar custom image, it comes out washed-up and stretched against a black navigation bar. This is how I create it: UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"gear.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(showSetting:)]; Here is what it looks like: Any idea if it's a problem with the image? I got it from a set of icons I bought. The displayed images on bar button items are 'derived' from the source image (it uses only the alpha channel values in