In iOS 7, I show actionSheet by "showFromRect":
[actionSheet showFromRect:rect inView:view animated:YES];
But in iOS 8, this doesn't work. They they replace the implementation and suggest us using UIAlertController. Then how do I show this actionSheet like a popover?
Using UIAlertController you can access the popoverPresentationController property to set the sourceView (aka inView) and sourceRect (aka fromRect). This gives the same appearance as the previous showFromRect:inView:
I also meet this problem like you, but my case is that I show a
UIActionSheet
inUIWindow.view
on the iPad device, and theUIWindow
doesn't setrootViewController
.So, I found, if we show a
UIActionSheet
in a window whoserootViewController
equals tonil
, theUIActionSheet
could not show out.My solution is to set
then,
Hope this will help you!
I found out the point is in iOS 7, you show
actionSheet
in a new window actually when using"showFromRect: inView:"
;But in iOS 8 you show the
actionSheet
just on the view you send in parameters.So the solution is to send
Me and my colleague figured it out by randomly trying.
according to this https://developer.apple.com/library/ios/documentation/Uikit/reference/UIActionSheet_Class/index.html thread UIActionSheet is deprecated, you should use UIAlertController instead of UIActionSheet.
Thanks.