UIBarButtonItem initWithImage landscapeImagePhone style target action
- (id)initWithImage:(UIImage *)image landscapeImagePhone:(UIImage *)landscapeImagePhone style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action
Parameters
image
The item’s image. If nil an image is not displayed.
landscapeImagePhone
The image to be used for the item in landscape bars in the UIUserInterfaceIdiomPhone idiom.
style
The style of the item. One of the constants defined in UIBarButtonItemStyle.
target
The object that receives the action message.
action
The action to send to target when this item is selected.
Return Value of [UIBarButtonItem initWithImage landscapeImagePhone style target action]
A new item initialized to use using the specified images and other properties
UIBarButtonItem initWithImage landscapeImagePhone style target action example.
// resize the image for landscape
UIImage *settingsImage = [UIImage imageNamed:@"settings"];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:settingsImage
landscapeImagePhone:[settingsImage resizedImage:CGSizeMake(17.f, 17.f) interpolationQuality:kCGInterpolationHigh]
style:UIBarButtonItemStyleBordered target:self action:@selector(settingsButtonClicked:)];
UIImage *settingsImage = [UIImage imageNamed:@"settings"];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:settingsImage
landscapeImagePhone:[settingsImage resizedImage:CGSizeMake(17.f, 17.f) interpolationQuality:kCGInterpolationHigh]
style:UIBarButtonItemStyleBordered target:self action:@selector(settingsButtonClicked:)];
Example of [UIBarButtonItem initWithImage landscapeImagePhone style target action].
//create toolbar and set origin and dimensions
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 428, 320, 32)];
//create buttons and set their corresponding selectors
UIBarButtonItem *button1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(button1Tap:)];
UIBarButtonItem *button2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRewind target:self action:@selector(button2Tap:)];
//if you want custom icons, use something like this:
UIBarButtonItem *button3 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon1_portrait.png"] landscapeImagePhone:[UIImage imageNamed:@"icon1_landscape.png"] style:UIBarButtonItemStylePlain target:self action:@selector(button3Tap:)];
//add buttons to the toolbar
[toolbar setItems:[NSArray arrayWithObjects:button1, button2, nil]];
//add toolbar to the main view
[self.view addSubview:toolbar];
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 428, 320, 32)];
//create buttons and set their corresponding selectors
UIBarButtonItem *button1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(button1Tap:)];
UIBarButtonItem *button2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRewind target:self action:@selector(button2Tap:)];
//if you want custom icons, use something like this:
UIBarButtonItem *button3 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon1_portrait.png"] landscapeImagePhone:[UIImage imageNamed:@"icon1_landscape.png"] style:UIBarButtonItemStylePlain target:self action:@selector(button3Tap:)];
//add buttons to the toolbar
[toolbar setItems:[NSArray arrayWithObjects:button1, button2, nil]];
//add toolbar to the main view
[self.view addSubview:toolbar];
UIBarButtonItem initWithImage landscapeImagePhone style target action example.
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithImage: landscapeImagePhone: style: target: action:]