Tech and a few other things RSS 2.0
# Sunday, February 13, 2011


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.

Sunday, February 13, 2011 11:10:30 PM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
iPad | Objective C | xCode
Navigation
About the author/Disclaimer
        

My name is Ben Coffman. I like to build things: programs, programming teams, programming departments and maybe one day a company with lots of programmers. When I turn the internet off I focus on my family, random hobbies, and sharing moments in life.

Blogs I follow:

1. 2andahalfd.com

2. Jeff Lamarche

3. Scott Hanselman

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Ben Coffman

Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
All Content © 2012,

Sign In