Friday, May 31, 2013

UIBarButtonItem UIBarButtonSystemItemRewind example in Objective C (iOS).


UIBarButtonItem UIBarButtonSystemItemRewind


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 UIBarButtonSystemItemRewind example.
    CustomToolbar* tools = [[CustomToolbar alloc] initWithFrame:CGRectMake(0, 0, 90, 48.01)];
    [tools setTintColor:[UIColor colorWithRed:0.62 green:0.70 blue:0.13 alpha:1.0]];

    NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:3];

    previousArticle = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRewind
                                                                                     target:self
                                                                                     action:@selector(displayPreviousArticle)];

    [previousArticle setStyle:UIBarButtonItemStyleBordered];
    [buttons addObject:previousArticle];

Example of [UIBarButtonItem UIBarButtonSystemItemRewind].
    //toolbar
UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 416, 320, 44)];

// bar btns
UIBarButtonItem *backBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRewind target:self action:@selector(goBack)];
UIBarButtonItem *forwardBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFastForward target:self action:@selector(goForward)];
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
UIBarButtonItem *bookmarkBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(bookmark)];
UIBarButtonItem *refreshBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh)];
UIBarButtonItem *stopLoadingBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop target:self action:@selector(stopLoading)];

// add btns to the bar
[toolBar setItems:[NSMutableArray arrayWithObjects:bookmarkBtn,backBtn,forwardBtn,flexibleSpace,refreshBtn,stopLoadingBtn, nil]];

// adds the toobar to the view
[self.view addSubview:toolBar];

UIBarButtonItem UIBarButtonSystemItemRewind example.
UIBarButtonItem *itemNull=[[[UIBarButtonItem alloc]   initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil] autorelease];
UIBarButtonItem *item0=[[[UIBarButtonItem  alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRewind target:self action:@selector(pre)] autorelease];
UIBarButtonItem *item1=[[[UIBarButtonItem  alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFastForward target:self action:@selector(pre)] autorelease];
UIBarButtonItem *item2=[[[UIBarButtonItem  alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(pre)] autorelease];
UIBarButtonItem *item3=[[[UIBarButtonItem  alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemReply target:self action:@selector(pre)]
    autorelease];
UIBarButtonItem *item4=[[[UIBarButtonItem  alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(pre)] autorelease];
[self.navigationController setToolbarHidden:NO animated:YES];
self.toolbarItems = [NSArray arrayWithObjects: itemNull, item0, item1, item2, item3, item4, nil];

End of UIBarButtonItem UIBarButtonSystemItemRewind example article.