Showing posts with label programmatically. Show all posts
Showing posts with label programmatically. Show all posts

Wednesday, July 28, 2010

iPhone: Add bar button item and set action method programmatically

UIBarButtonItem *rButton =[[UIBarButtonItem alloc] init];

rButton.title= @"someText";
[rButton setTarget:self];
[rButton setAction:@selector(aMethod)]; //aMethod defined in the class
self.navigationItem.rightBarButtonItem=rButton;

Tested & working in my project!

Happy Coding :)