Friday, May 31, 2013

UIBarButtonItem UIBarButtonSystemItemSave example in Objective C (iOS).


UIBarButtonItem UIBarButtonSystemItemSave


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 UIBarButtonSystemItemSave example.
UIBarButtonItem* saveItem = [[UIBarButtonItem alloc]  initWithBarButtonSystemItem:UIBarButtonSystemItemSave
    target:self action:@selector(saveButtonClicked:)];
self.navigationItem.rightBarButtonItem = saveItem;
[saveItem release];

Example of [UIBarButtonItem UIBarButtonSystemItemSave].
- (void)viewDidLoad {
    [super viewDidLoad];
self.title = @"Settings";
self.navigationItem.hidesBackButton = YES;


UIBarButtonItem* saveItem = [[UIBarButtonItem alloc]  initWithBarButtonSystemItem:UIBarButtonSystemItemSave
   target:self action:@selector(/*some method to send data back*/)];
self.navigationItem.rightBarButtonItem = saveItem;
[saveItem release];

UIBarButtonItem UIBarButtonSystemItemSave example.
// create a standard save button
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc]
    initWithBarButtonSystemItem:UIBarButtonSystemItemSave
    target:self
    action:@selector(saveAction:)];
saveButton.style = UIBarButtonItemStyleBordered;
[buttons addObject:saveButton];
[saveButton release];

End of UIBarButtonItem UIBarButtonSystemItemSave example article.