Ios 为什么不';UI支持界面方向设置是否影响UIViewController行为?

Ios 为什么不';UI支持界面方向设置是否影响UIViewController行为?,ios,uiviewcontroller,bundle,resourcebundle,Ios,Uiviewcontroller,Bundle,Resourcebundle,Xcode(4)突出显示了UISupportedInterfaceOrientations设置,但无论我如何设置它们,它似乎都不会影响基本应用程序的功能。Xcode templates insert注释掉了以下内容中的编程报告支持实现: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orien

Xcode(4)突出显示了UISupportedInterfaceOrientations设置,但无论我如何设置它们,它似乎都不会影响基本应用程序的功能。Xcode templates insert注释掉了以下内容中的编程报告支持实现:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
根据我的经验,此代码与应用程序的捆绑设置无关。因此,我编写了以下代码,根据应用程序设置自动报告对定向的支持

为什么这不是默认的实现?我是否遗漏了一些东西,而这些代码应该是不必要的?(有人能提出什么改进吗?)

/**
 * This implementation coordinates the app's orientation support with the app
 * bundle settings, simplifying the configuration of the app's support for its
 * different orientations. 
 */
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    static NSString *_orientationFlagNames[] = {
        Nil,                                        // UIDeviceOrientationUnknown
        @"UIInterfaceOrientationPortrait",          // UIDeviceOrientationPortrait,
        @"UIInterfaceOrientationPortraitUpsideDown",// UIDeviceOrientationPortraitUpsideDown,
        @"UIInterfaceOrientationLandscapeRight",    // UIDeviceOrientationLandscapeLeft [sic]
        @"UIInterfaceOrientationLandscapeLeft"      // UIDeviceOrientationLandscapeRight [sic]
                                                    // UIDeviceOrientationFaceUp
                                                    // UIDeviceOrientationFaceDown
    };

    NSArray *supportedOrientation = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"];

    BOOL shouldRotate = (interfaceOrientation < sizeof(_orientationFlagNames)/sizeof(NSString*)
        && [supportedOrientation containsObject:_orientationFlagNames[interfaceOrientation]]);
    return shouldRotate; 
}
/**
*此实现将应用程序的定向支持与应用程序相协调
*捆绑设置,简化应用程序对其应用程序的支持配置
*不同的方向。
*/
-(布尔)应自动旋转指针面定向:(UIInterfaceOrientation)interfaceOrientation{
静态NSString*\U方向标记名[]={
无,//UIDeviceOrientationUnknown
@“UIInterfaceOrientationPortrait”//UIDeviceOrientationPortrait,
@“UIInterfaceOrientationGraphitoUpsideDown”,//UIDeviceOrientationGraphitoUpsideDown,
@“UIInterfaceOrientationAndscapeRight”,//UIDeviceOrientationAndscapeLeft[sic]
@“UIInterfaceOrientationAndscapeLeft”//UIDeviceOrientationAndscapeRight[原文如此]
//UIDeviceOrientationFaceUp
//UIDeviceOrientation面朝下
};
NSArray*supportedOrientation=[[NSBundle mainBundle]信息字典]objectForKey:@“UISupportedInterfaceOrientations”];
BOOL shouldRotate=(接口方向
我认为这里有区别。
info.plist
值表示应用程序支持的方向,而
shouldAutorotateToInterfaceOrientation:
表示特定视图的可用方向


如果你看一下,就会清楚地看到,
info.plist
值帮助iOS选择启动应用程序的初始方向。

我认为这里有一个区别。
info.plist
值表示应用程序支持的方向,而
shouldAutorotateToInterfaceOrientation:
表示特定视图的可用方向


如果您查看,就会清楚地看到,
info.plist
值帮助iOS选择启动应用程序的初始方向。

您的链接上说,“…指定应用程序支持的界面方向。系统使用此信息(以及当前设备方向)选择启动应用程序的初始方向。”我只阅读了声明的第一部分,但我猜它实际上是说设置指示了支持的初始方向。我的解释正确吗?它是这样读的,但事实并非如此——如果你没有在这里指定你需要的所有方向,你的应用程序将不会旋转到它们,即使在启动之后。如果我错了,请有人纠正我。你的链接说,“…指定你的应用程序支持的界面方向。系统使用此信息(以及当前设备方向)来选择启动应用程序的初始方向。”我只阅读了声明的第一部分,但我猜它实际上是说,设置指示初始支持的方向。我的解释正确吗?它是这样读的,但事实并非如此——如果你没有在这里指定你需要的所有方向,你的应用程序将不会旋转到它们,即使在启动之后。如果我错了,请有人纠正我。