
Problem:Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Popovers cannot be presented from a UIBarButtonItem that is not in a toolbar or navigation bar already.'
Solution:You can get the error for a number of reasons, but I'm betting it's because you didn't declare your UIBarButtonItem correctly in either your header file or your implementation file. You might have done something like this in your header file.
@interface TestInterface : UIViewController <UIPopoverControllerDelegate, UISplitViewControllerDelegate>
{
UIButtonItem *button
}
@property (nonatomic, retain) IBOutlet UIBarButtonItem *Button;Notice the Button variable is declared with one "B" capitalized and the other "b" is not.
And then in your implementation file you tried to call the button by using the non-capitalized declaration.
Like so:
[poc presentPopoverFramBarButtonItem:button ...];
Explanation:Usually what causes this is, what I would consider, but technically is not, a syntax error. You tried to call a variable that doesn't exist, kinda. The real kicker is there is no compile error. Which is correct, as you should be able to declare code as such in the header file, it just makes it easy for the user to reference the incorrect variable name.