views:

56

answers:

1

Hi all,

In my application, I'm presenting a modalViewController with a navigationbar on the top of it, but I'm not able to add barbuttons to the navigatiobar. I'm using following code:

EDIT:

displayController = [[UIViewController alloc]initWithNibName:nil bundle:nil];

UINavigationController *cntrol = [[UINavigationController alloc] initWithRootViewController:displayController];

[displayController setTitle:@"TEST"];


UIBarButtonItem *submit = [[UIBarButtonItem alloc]
                            initWithBarButtonSystemItem:UIBarButtonSystemItemDone
                            target:self
                            action:@selector(displayViewForPosts)];

displayController.navigationItem.rightBarButtonItem = submit;
[submit release];

UIBarButtonItem *newsfeed = [[UIBarButtonItem alloc]
                           initWithBarButtonSystemItem:UIBarButtonSystemItemDone
                           target:self
                           action:@selector(displayViewForPosts)];
displayController.navigationItem.leftBarButtonItem = newsfeed;
[newsfeed release];

[self presentModalViewController:cntrol animated:YES];
[cntrol release];
[displayController release];

Thanx in advance.

+1  A: 
UIViewController *detailViewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];

UINavigationController *cntrol = [[UINavigationController alloc] initWithRootViewController:detailViewController];

[detailViewController setTitle:@"TEST"];


UIBarButtonItem *submit = [[UIBarButtonItem alloc]
                           initWithBarButtonSystemItem:UIBarButtonSystemItemDone
                           target:self
                           action:@selector(displayViewForPosts)];
detailViewController.navigationItem.rightBarButtonItem = submit;
[submit release];


[self.navigationController presentModalViewController:cntrol animated:YES];
[cntrol release];
Aaron Saunders
Thanx Aaron for your reply, but it's still not working.. I've edited my question with updated code.. Can you please tell me where I'm going wrong?
neha
What problems are you having? Is the modal view still not showing?
Aaron Saunders
No, modalview was showing up earlier too.. I don't know how but suddenly the buttons appeared.. Thanx for your help..
neha
Ok, there's a problem.. These buttons are showing up like normal toolbar buttons with no direction as the navigationbarbuttons. I wanted those type of directional buttons which will be better for user.
neha
I am looking at this and more and more I thing you dont want to use presentModalViewController, I think you just want to push the new view onto the existing navigationController stack.was there a reason you choose presentModalViewController?
Aaron Saunders
also If I have been helpful.... alittle reputation is appreciated :-)
Aaron Saunders