views:

165

answers:

2

Hi, i'm trying to develop my first iphone apps. I'm using a navigationController with three views: main->first view ->second view. I would like to add a button only on the first view, i tried like this:

self.navigationItem.rightBarButtonItem = self.editButtonItem;

but nothing appear. If I add the button on the main view it appears after on each view, is possible to do what I want? Thanks!

A: 
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"YOUR TITLE" style:UIBarButtonItemStylePlain target:nil action:nil] autorelease];
Thomas Clayson
It exactly what I did but it doesn't work! Nothing appear
PiccoloBuddha
how do you push view controllers? Can you give me the exact line you use? it will be something similar to: `[self.navigationController pushViewController:nextPage animated:YES];`
Thomas Clayson
it's:[self.navigationController pushViewController:tab animated:YES]; where tab has a TabBarController with 3 other views inside, and if I put a button on tab class it becomes visible in each of the view that are inside the tabController
PiccoloBuddha
hmm then i have no idea why that isn't working.. can you post your whole source code in your op?
Thomas Clayson
In ProfileView.m: TabViewLast *tab = [[TabViewLast alloc]init]; [self.navigationController pushViewController:tab animated:YES]; In TabViewLast.m: There are three instance for each view on the tabBar (e.g DetailView *det =...; UITabBarItem *detItem =... and det.tabBarItem=detItem) UITabBarController *tabBarController = [[UITabBarController alloc] init];[self.view addSubview:tabBarController.view];So i can only modify the navigationController on the TabViewLast class
PiccoloBuddha
A: 
UIButton *button =  [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"buttonImage.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
[button setFrame:CGRectMake(0, 0, 49, 30)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
Ashish Mathur
Nothing appear, maybe the navigation bar is used by every view and it's not possible to add a button only to one. I don't know if it changes something but my first view contain a tabBar that contains other three view too
PiccoloBuddha