繁体   English   中英

iphone-在iphone方向更改时,仅旋转一个控件,而不旋转所有其他控件

[英]iphone - On orientation change of iphone , rotate only one control and not all others

我在视图中有UIImageView,几个标签,按钮等。 目前,我已经实现了肖像模式。 当iPhone的方向改变时,我只想旋转图像视图。 其余所有其他控件均不应更改。 如何实现仅图像视图的旋转?

最近我不得不做一些非常相似的事情。 我所做的是禁用自动旋转,然后使用如下设备通知:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];

- (void)didRotate:(NSNotification *)notification {  
    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    switch (orientation) {
        case UIDeviceOrientationUnknown:
        case UIDeviceOrientationFaceUp:
        case UIDeviceOrientationFaceDown:
            return;
            break;
    }

    // Do something
}

您将需要处理一些快速旋转等情况。如果您需要更多信息,请告诉我。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM