How to do “actionSheet showFromRect” in iOS 8?

前端 未结 4 471
旧巷少年郎
旧巷少年郎 2021-01-13 16:03

In iOS 7, I show actionSheet by \"showFromRect\":

[actionSheet showFromRect:rect inView:view animated:YES];

But in iOS 8, this doesn\'t wor

4条回答
  •  野的像风
    2021-01-13 16:18

    I also meet this problem like you, but my case is that I show a UIActionSheet in UIWindow.view on the iPad device, and the UIWindow doesn't set rootViewController.

    So, I found, if we show a UIActionSheet in a window whose rootViewController equals to nil, the UIActionSheet could not show out.

    My solution is to set

    window.rootViewController = [[UIViewController alloc] init];
    

    then,

    [actionSheet showFromRect:rect inView:window.rootViewController.view animated:YES].
    

    Hope this will help you!

提交回复
热议问题