UIBarButtonItem initWithBarButtonSystemItem target action
- (id)initWithBarButtonSystemItem:(UIBarButtonSystemItem)systemItem target:(id)target action:(SEL)action
Parameters
systemItem
The system item to use as the first item on the bar. One of the constants defined in UIBarButtonSystemItem.
target
The object that receives the action message.
action
The action to send to target when this item is selected.
Return Value of [UIBarButtonItem initWithBarButtonSystemItem target action]
A newly initialized item containing the specified system item. The item’s target is nil.
UIBarButtonItem initWithBarButtonSystemItem target action example.
-(void)viewDidload
{
app.navigationController.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(Add:)] autorelease];
}
-(IBAction)Add:(id)sender
{
TAddNewJourney *j=[[TAddNewJourney alloc]init];
[app.navigationController pushViewController:j animated:YES];
[j release];
}
{
app.navigationController.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(Add:)] autorelease];
}
-(IBAction)Add:(id)sender
{
TAddNewJourney *j=[[TAddNewJourney alloc]init];
[app.navigationController pushViewController:j animated:YES];
[j release];
}
Example of [UIBarButtonItem initWithBarButtonSystemItem target action].
UIBarButtonItem *rButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self
action:@selector(refreshAction)];
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self
action:@selector(refreshAction)];
UIBarButtonItem initWithBarButtonSystemItem target action example.
static inline UIBarButtonItem *BarButtonWithSystemStyle(UIBarButtonSystemItem style, id target, SEL action)
{
return [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:style target:target action:action] autorelease];
}
static inline UIBarButtonItem *BarButtonWithFlexibleWidth(id target, SEL action)
{
return [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:target action:action] autorelease];
}
static inline UIBarButtonItem *BarButtonWithFixedWidth(CGFloat width, id target, SEL action)
{
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:target action:action];
button.width = width;
return [button autorelease];
}
{
return [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:style target:target action:action] autorelease];
}
static inline UIBarButtonItem *BarButtonWithFlexibleWidth(id target, SEL action)
{
return [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:target action:action] autorelease];
}
static inline UIBarButtonItem *BarButtonWithFixedWidth(CGFloat width, id target, SEL action)
{
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:target action:action];
button.width = width;
return [button autorelease];
}