I am using the following code to retrieve some messages and putting them into my inbox.
MyInboxVC *inboxVC=[MyInboxVC get ];
//upload all the pending messag
It means that the ViewController
returned from [MyInboxVC get]
is already in the navigation stack of devNavController
. You can not add the same object to the stack multiple times.
Apparently, you already have a MyInboxVC
pushed earlier. Insure that you've popped it when it was no longer needed.
That's the "what's it mean" answer, but don't have enough info to know what you need to do to fix it.
My guess is your Navigation Stack is growing larger than you are expecting, meaning you are not popping as often as you should.
This is an expected behavior of UINavigationController where an exception is thrown when trying to push a view controller which is already present in the stack (Its there from iOS 2.2).
This was happening to me on a bar button click happening too fast, and was hard to reproduce, unless you went nuts on the button taps. The following fixed it by disabling the the button, starting the nav push, then enabling the button on the main thread (because it would be called after animation from the push occurred).
- (void)showMore
{
self.navigationItem.leftBarButtonItem.enabled = NO;
[self.navigationController pushViewController:moreVC animated:YES];
[self.navigationItem.leftBarButtonItem performSelectorOnMainThread:@selector(setEnabled:) withObject:@(YES) waitUntilDone:NO];
}
In my case i was pushing a viewcontroller, but then also trying to clear the navigation stack so that there was no vc's to pop to after this new VC had shown
self.show(viewController, sender: nil)
if clearNavigationStack {
self.navigationController?.viewControllers = [viewcontroller]
}
you cant do this directly after pushing a viewcontroller, you will need to wait till the viewcontroller has fully shown before trying to reset the navigation stack
Are you performing this as part of a segue? If you are, there is no need to push a VC onto your Navigation Controller because the segue will do it already. That is why your error is occurring - you are pushing a VC that is already on the stack of the NavController.
Another option that I have experienced is that [MyInboxVC get ] is not returning an instance of a MyInboxVC object at all. A tell tale sign of this would be that the error is saying 'Pushing the same view controller instance more than once is not supported (notTheInboxVC: 0x9e31660)' ie. the class being pushed more than once is not the MyInboxVC expected (a fall through from MyInboxVC not being allocated)