views:

460

answers:

2

Hi,

In my iphone application i have added the Uitable view.While launching the application the table is showing the No. of rows which i want.Now i want to add the Navigation bar to the UiTable,also i want to add the edit button on the left side of the navigation bar.

How to add the Navigation bar in the UiTable view in iphone?I dont want to use the UiNavigation Based application.i want to add using the code. If anybody has any useful code or any other useful link or other solution,which would be appreciated. Please be needful.

Thanks,

Mishal Shah

A: 

You should probably tag this as iPhone.

Antony Koch
+1  A: 

Easy assuming you have your list managed by a UITableViewController, and aslo bite down ont he bullet and actually use the UINavigationController as you should. Then override your viewDidLoad as this:

-(void)viewDidLoad;
{
  [super viewDidLoad];
  self.navigationItem.leftBarButtonItem = [self editButtonItem];
}

If you for some strange reason really do need to use your own UINavigationBar, then you have to add some extra code. Perhaps something like this:

-(void)viewDidLoad;
{
  [super viewDidLoad];
  UINavigationBar* navBar = self.myOwnStupidNavigationBar;
  UINavigationItem* navItem = self.navigationItem;
  navItem.leftBarButtonItem = [self editButtonItem];
  navbar.items = [NSArray arrayWithObject:navItem];
}

But think not twice, but ten times over, if you really have a good reason not to use UINavigationController that gives you allot of nice functionality for free.

PeyloW
Thanks for fast reply.Its really nice advice from u r side,which would really help me in my thinking process at other side.
Mishal