我指的是 DMD Panorama 应用程序。
如您所见,此图片的顶部有一个阴阳符号。
一旦我们旋转设备,两个符号就会靠近,如下所示:
能否请您告诉我如何检测设备的旋转,以便当设备旋转时,这两张图像靠得更近?
感谢您的回复。
最佳答案
在 viewWillAppear 函数中添加通知器
-(void)viewWillAppear:(BOOL)animated{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];}
方向改变通知这个函数
- (void)orientationChanged:(NSNotification *)notification{
[self adjustViewsForOrientation:[[UIApplication sharedApplication] statusBarOrientation]];}
在处理 moviePlayerController 帧的方向时依次调用此函数
- (void) adjustViewsForOrientation:(UIInterfaceOrientation) orientation {
if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
{
//load the portrait view
}
else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
//load the landscape view
}}
在 viewDidDisappear 移除通知
-(void)viewDidDisappear:(BOOL)animated{
[[NSNotificationCenter defaultCenter]removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];}
关于iphone - 如何在 iOS 中实现这一点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19109165/