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 :)

2 comments:

  1. I think this site is really awesome and informational to me and i am also gonna share this to my friends. Thanks for such nice information's.

    ReplyDelete
    Replies
    1. thanks, I wish I could keep it up to date and more informational... Happy Coding!

      Delete