Custom UIWindows do not rotate correctly in iOS 8

前端 未结 4 585
情歌与酒
情歌与酒 2021-02-05 12:46

Get your application into landscape mode and execute the following code:

UIWindow *toastWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];         


        
4条回答
  •  情书的邮戳
    2021-02-05 13:09

    In iOS 7 and earlier, UIWindow's coordinate system did not rotate. In iOS 8 it does. I am guessing the frame supplied from [[UIScreen mainScreen] bounds] does not account for rotation, which could cause issues like what you're seeing.

    Instead of getting the frame from UIScreen, you could grab the frame from the appDelegate's current key window.

    However, it does not appear you really need functionality supplied by UIWindow. I'd like to echo others' recommendation that you use a UIView for this purpose. UIView is more generic than UIWindow, and should be preferred.

提交回复
热议问题