在初始UIImageView中,我将其设置为
mCurrentImageView.contentMode = UIViewContentModeLeft;因此,如果设备旋转,我将更改contentMode,但它没有任何影响。我怎么才能修复它?
if ([UIDevice currentDevice].orientation == UIInterfaceOrientationLandscapeLeft || [UIDevice currentDevice].orientation == UIInterfaceOrientationLandscapeRight) {
mCurrentImageView.contentMode = UIViewContentModeScaleAspectFit;
}发布于 2010-06-03 21:43:45
UIDevice orientation不返回方向的那些标识符。从文档中,该消息将返回以下内容:
typedef enum {
UIDeviceOrientationUnknown,
UIDeviceOrientationPortrait,
UIDeviceOrientationPortraitUpsideDown,
UIDeviceOrientationLandscapeLeft,
UIDeviceOrientationLandscapeRight,
UIDeviceOrientationFaceUp,
UIDeviceOrientationFaceDown
} UIDeviceOrientation;要更改内容模式,您应该在willRotate消息中的视图控制器代码中执行一些操作:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
mCurrentImageView.contentMode = UIViewContentModeScaleAspectFit;
}
}https://stackoverflow.com/questions/2965256
复制相似问题