相关疑难解决方法(0)

如何在iOS上检测设备的方向?

我有一个关于如何在iOS上检测设备方向的问题.我不需要接收更改通知,只需要接收当前方向.这似乎是一个相当简单的问题,但我无法绕过它.以下是我到目前为止所做的事情:

UIDevice *myDevice = [UIDevice currentDevice] ;
[myDevice beginGeneratingDeviceOrientationNotifications];
UIDeviceOrientation deviceOrientation = myDevice.orientation;
BOOL isCurrentlyLandscapeView = UIDeviceOrientationIsLandscape(deviceOrientation);
[myDevice endGeneratingDeviceOrientationNotifications];
Run Code Online (Sandbox Code Playgroud)

在我看来这应该工作.我启用设备接收设备方向通知,然后询问它的方向,但它不起作用,我不知道为什么.

objective-c orientation uidevice ios

71
推荐指数
6
解决办法
10万
查看次数

screen.width/screen.height在屏幕旋转后不更新

我在iPhone设备上遇到了这个问题(iPhone 7,iOS 10,还有其他iPhone):在javascript中,如果我拦截orientationchange事件,在处理程序内部,screen.width和screen.height保持不变(如在轮换之前).

由于这可能取决于视口设置,因此我的视口在.html文件中的声明方式如下:

<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1, maximum-scale=1, user-scalable=no" />
Run Code Online (Sandbox Code Playgroud)

在Chrome的模拟可视化中,一切正常.

在此先感谢您的帮助.

javascript iphone screen-orientation ios

13
推荐指数
2
解决办法
7101
查看次数

旋转后UIDocumentInteractionController消失

我用来UIDocumentInteractionController与设备上的其他应用共享数据

 self.docInteraction = [UIDocumentInteractionController interactionControllerWithURL:imageAttachFile];
 self.docInteraction.delegate = self;
 [self.docInteraction presentOpenInMenuFromRect:CGRectZero inView: self.view animated: YES ];
Run Code Online (Sandbox Code Playgroud)

它工作得很好,但它在设备旋转后消失了.它的原因是什么以及如何解决这个问题?

objective-c ios uidocumentinteraction

5
推荐指数
1
解决办法
873
查看次数