我有一个xib文件进入画廊选择一些照片,我在我的项目中定义他只支持 LandscapeLeft 和 LandscapeRight 这些方向,所以当我点击我的按钮并打开我的应用程序崩溃的图像库并向我发送消息:
支持的方向与应用程序没有共同的方向, 并且shouldAutorotate将返回YES
在互联网上快速搜索,我发现他可以使用命令:
-(BOOL)shouldAutorotate {
return NO;
}
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft;
}
我将此代码放在.m文件中,但不起作用!并且我不断收到错误消息,应用程序崩溃了。所以我想知道是否是必须的,当我们访问照片库时设备处于纵向位置,如果没有,我怎么能解决这个问题呢?