Instead of passing the current view controller's view to the action sheet, use the showFromTabBar:
method of UIActionSheet
.
The Right Way
This will give the correct tappable area:
[actionSheet showFromTabBar:self.tabBarController.tabBar];
The Wrong Way
This will put the tappable area in the wrong place (if you're using a tab bar or toolbar):
[actionSheet showInView:self.view];
If you're using a toolbar, use the showFromToolbar:
method instead. You'll need a reference to the toolbar, most likely an ivar
[actionSheet showFromToolbar:self.myToolbar];
My Old Answer Also works, but is hacky:
Just found a possible answer:
01-Dec-2008 10:22 PM Tom Saxton:
I looked at this bug some more, and it seems to be an issue with the tabbar.
If you call UIActionSheet's [sheet showInView:self.view] from a view controller that is a child of a UITabViewController, then the hit testing on the cancel button fails in that portion of the UIActionSheet that lies above the tabbar's view.
If you instead pass in the UITabBarController's view, then the UIActionSheet acts as expected.
NOTE: in iPhone OS 2.1 and earlier, the UIActionSheet came up from the top of the tab bar when you pass the child view, but in 2.2, it comes up from the bottom of the tab bar, and thus covers the tab view.
http://openradar.appspot.com/6410780
Edit: It works correctly when I change the view to be the tab bar's view
[sheet showInView:self.parentViewController.tabBarController.view];
You may have a bad connection in your xib.
I've had this error many times. While TechZen's answer is absolutely right in this case, another common cause is when you change the name of a IBOutlet property in your .h/.m which you've already connected up to File's Owner in the nib.
From your nib:
- Select the object in IB and go to the 'Connections Inspector'.
Under 'Referencing Outlets' make sure that your object isn't still connected to the old property name... if it is, click the small 'x' to delete the reference and build again.
Another common cause if you are using Storyboard, your UIButton might have more then one assignings (Solution is almost the same as for nib):
- Open your storyboard and right click the UIButton
You will see that there is more than one assign/ref to this button.
Remove one of the "Main..." greyed windows with the small "x":
Best Answer
I got this to work (you just need to, be ok with a regular button, and just add it after :