This is pretty straightforward, I have a view which is called when user tap “+” button on top navigation bar in my first view, then, second view appear. My problem is, I can’t set any button on my second view navigation bar, actually I tried to set it like I usually did, like I set my “+” button, but nothing works. This is how I set button:
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addProduct:)];
self.navigationItem.leftBarButtonItem = addButton;
Then I call my second view:
BIDAddProductViewController *addProductVC = [[BIDAddProductViewController alloc] init];
[self presentModalViewController:addProductVC animated:YES];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(hideModalViewController:) name:@HideModalViewController" object:addProductVC];
Please, help me to set button on my second (BIDAddProductViewController) view, nothing’s working, I don’t know why.
The problem is the way you’re presenting the second controller. Instead of pushing it into the navigation stack, you present it modally and that’s why you don’t get a ‘back’ button. What you really should be doing is something like this: