Friday, May 31, 2013

UIBarButtonItem UIBarButtonSystemItemCancel example in Objective C (iOS).


UIBarButtonItem UIBarButtonSystemItemCancel


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 UIBarButtonSystemItemCancel example.
-(IBAction)visitFacebook{
WebViewViewController *rootController = [[WebViewViewController alloc] init];
rootController.webURL = @"http://www.facebook.com/";
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootController];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc ] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(done:)];

 rootController.navigationItem.rightBarButtonItem = anotherButton;

[navigationController.navigationItem setTitle:@"Facebook"];

if (rootController) {
    [self presentModalViewController:navigationController animated:YES];
}

[doneButton release];
[rootController release];

}

Example of [UIBarButtonItem UIBarButtonSystemItemCancel].
UIBarButtonItem *closeButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(shutDown)] autorelease];
self.navigationItem.leftBarButtonItem = closeButton;

UIBarButtonItem UIBarButtonSystemItemCancel example.
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc ]
                           initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
                           target:graphView
                           action:@selector(dismissView)];

End of UIBarButtonItem UIBarButtonSystemItemCancel example article.