Search code examples
objective-ccocoa-touchiosuiactionsheet

UIActionSheet not rotating in landscape mode?


I have a UIActionSheet and I set it's view like this:

[popup showInView:[[UIApplication sharedApplication] keyWindow]];

this works fine in portrait mode, but when I switch to landscape, it stays portrait. What am I doing wrong? Thanks.


Solution

  • You're showing it in the window (which is not rotated), rather than in a view controller's view (which is). Pass the main view of your currently-visible view controller instead, or use showFromTabBar: or showFromToolbar: on iPhone or showFromBarButtonItem:animated: or showFromRect:inView:animated: on iPad.