How to detect Orientation Change in Custom Keyboard Extension in iOS 8?

后端 未结 10 1939

In Custom Keyboard Extension , we can\'t use

`didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation` 

and

10条回答
  •  余生分开走
    2020-12-04 18:38

    There is a simple way, just looking at the screen width:

     double width = [[UIScreen mainScreen] bounds].size.width;
     double interfaceWidth = MIN([[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height);
    
     BOOL isPortrait = (width == interfaceWidth) ? YES : NO;
    

提交回复
热议问题