Friday, May 31, 2013

UIBarButtonItem UIBarButtonSystemItemEdit example in Objective C (iOS).


UIBarButtonItem UIBarButtonSystemItemEdit


UIBarButtonSystemItem
Defines system-supplied images for bar button items.

typedef enum {
UIBarButtonSystemItemDone,
UIBarButtonSystemItemCancel,
UIBarButtonSystemItemEdit,
UIBarButtonSystemItemSave,
UIBarButtonSystemItemAdd,
UIBarButtonSystemItemFlexibleSpace,
UIBarButtonSystemItemFixedSpace,
UIBarButtonSystemItemCompose,
UIBarButtonSystemItemReply,
UIBarButtonSystemItemAction,
UIBarButtonSystemItemOrganize,
UIBarButtonSystemItemBookmarks,
UIBarButtonSystemItemSearch,
UIBarButtonSystemItemRefresh,
UIBarButtonSystemItemStop,
UIBarButtonSystemItemCamera,
UIBarButtonSystemItemTrash,
UIBarButtonSystemItemPlay,
UIBarButtonSystemItemPause,
UIBarButtonSystemItemRewind,
UIBarButtonSystemItemFastForward,
UIBarButtonSystemItemUndo, // iOS 3.0 and later
UIBarButtonSystemItemRedo, // iOS 3.0 and later
UIBarButtonSystemItemPageCurl, // iOS 4.0 and later
} UIBarButtonSystemItem;

UIBarButtonItem UIBarButtonSystemItemEdit example.
UIBarButtonItem *editButton = [[UIBarButtonItem alloc]
                              initWithBarButtonSystemItem:UIBarButtonSystemItemEdit
                              target:self
                              action:@selector(deleteAction:)];
editButton.style = UIBarButtonItemStyleBordered;
[buttons addObject:editButton];
[editButton release];

Example of [UIBarButtonItem UIBarButtonSystemItemEdit].
UIBarButtonItem *button1 = [[UIBarButtonItem alloc]
                            initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
                            target:self action:@selector(b1Action:)];
UIBarButtonItem *button2 = [[UIBarButtonItem alloc]
                            initWithBarButtonSystemItem:UIBarButtonSystemItemEdit
                            target:self action:@selector(b2Action:)];
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:button1, button2, nil];

UIBarButtonItem UIBarButtonSystemItemEdit example.
-(void)done:(id)sender
{
        UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self
action:@selector(delete:)];
        self.navigationItem.rightBarButtonItem = barButtonItem;
        [barButtonItem release];
        editando = NO;
}

End of UIBarButtonItem UIBarButtonSystemItemEdit example article.