noob question regarding ios development.
In a previous project, I have a UITableViewController, to which I am adding a button in the viewDidLoad method, like this:
UIBarButtonItem *button = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self
action:@selector(addMeasurement:)];
self.navigationItem.rightBarButtonItem = button;
[button release];
This works great.
I now have another application in which I am trying to do the same thing, except now I have a UITabBarControllerDelegate at the top (the default that comes along with “Tab Bar Application”), whose first view is the UITableViewController.
The First View has no nib as it’s just a table. I am trying to do the same thing with the same code, trying to add a button in the viewDidLoad method, but it’s not working.
So in the firstViewController (which is a UITableViewController) I am adding the above code to the viewDidLoad method, with no success.
It is showing data in the table, however (from a managedObjectContext). I’ve also tried putting the code in the “initWithStyle” method of the firstViewController but that doesn’t work either.
Any ideas? Clearly I’m not understanding something.
Thanks!
Do this.
Create the Tab Bar Controller and set it as your rootController.
Set your First View controller as a Navigation View controller.
Create a new file which is a subclass of the UITableViewController.
If you have any more doubts; please watch this tutorial on how to do all of these.
http://www.youtube.com/watch?v=LBnPfAtswgw