i want add right bar button item navigation bar, on click, performs function.
i have created following code add right bar button item, after done, bar button item not getting displayed in navigation bar:
-(void)viewdidload{ self.navigationitem.rightbarbuttonitem = [[[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemadd target:self action:@selector(add:)] autorelease]; } -(ibaction)add:(id)sender { taddnewjourney *j=[[taddnewjourney alloc]init]; [app.navigationcontroller pushviewcontroller:j animated:yes]; [j release]; }
-(void)viewdidload { [super viewdidload]; app.navigationcontroller.navigationitem.rightbarbuttonitem = [[[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemadd target:self action:@selector(add:)] autorelease]; } -(ibaction)add:(id)sender { taddnewjourney *j=[[taddnewjourney alloc]init]; [app.navigationcontroller pushviewcontroller:j animated:yes]; [j release]; }
try other answers. posted answer work if viewcontroller not have navigation controller think problem.
Comments
Post a Comment