Sheet can not be presented because the view is not in a window的解决办法,和window的简单使用

Sheet can not be presented because the view is not in a window,顺便在stackoverflow上找了答案,希望能给大家带来帮助,在此感谢我的朋友们。

1.

UIWindow* window =[[UIApplication sharedApplication] keyWindow];

if([window.subviews containsObject:self.view])

{[emailSheet showInView:self.view];}

else{[emailSheet showInView:window];}
2.
[actionSheet showInView:[[[[UIApplication sharedApplication] keyWindow] subviews] lastObject]];
原文地址:https://www.cnblogs.com/huntaiji/p/3593222.html