Friday, May 31, 2013

UIBarButtonItem UIBarButtonSystemItemOrganize example in Objective C (iOS).


UIBarButtonItem UIBarButtonSystemItemOrganize


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 UIBarButtonSystemItemOrganize example.
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
    UIBarButtonItem *menuItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize
                                                                                  target:self
                                                                                  action:@selector(menuItemSelected:)];
    [self.navigationItem setLeftBarButtonItem:menuItem];

    [viewController.navigationItem setLeftBarButtonItem:menuItem];
}

Example of [UIBarButtonItem UIBarButtonSystemItemOrganize].
    // create a save button
    downloadButton = [[UIBarButtonItem alloc]
                      initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:nil action:@selector(download)];
    [buttons addObject:downloadButton];
    [downloadButton release];

UIBarButtonItem UIBarButtonSystemItemOrganize example.
 - (void)viewDidLoad {
    UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithCustomView:activityIndicator];
    [self navigationItem].rightBarButtonItem = barButton;

    [activityIndicator startAnimating];

    [self callStudentsWebService];
    [super viewDidLoad];
    self.clearsSelectionOnViewWillAppear = NO;
    self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
    [self setTitle:@"Students"];

    self.navigationController.toolbarHidden = NO;
    self.navigationController.toolbar.barStyle = UIBarStyleBlack;
     UIBarButtonItem *add = [[UIBarButtonItem alloc] initWithTitle:@"Add Student"        style:UIBarButtonItemStyleBordered target:self action:@selector(addStudent)];
    UIBarButtonItem *flexible = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
    UIBarButtonItem *import =  [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:@selector(addStudent)];
    NSArray* toolbarItems = [NSArray arrayWithObjects:add,flexible,import, nil];
    self.toolbarItems = toolbarItems;
  }

End of UIBarButtonItem UIBarButtonSystemItemOrganize example article.