为什么UISupportedInterfaceOrientations设置不会影响UIViewController的行为?

| Xcode(4)突出显示了UISupportedInterfaceOrientations设置,但是无论我如何设置,它似乎都不会影响基本应用程序的功能。 Xcode模板插入注释掉的实现,用于以编程方式报告对以下内容的支持:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
以我的经验,此代码与应用程序的捆绑软件设置无关。因此,我编写了以下代码,以根据应用程序设置自动报告对方向的支持。 为什么这不是默认实现?我错过了什么吗?不需要此代码吗? (有人可以提出任何改进建议吗?)我可能会将其变成UIViewController的类别。
/**
 * 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; 
}
    
已邀请:
        我认为这是有区别的。
info.plist
值指示应用程序支持的方向,而
shouldAutorotateToInterfaceOrientation:
值指示特定视图可用的方向。 如果您看到
here
,显然会提到mentioned2ѭ值可帮助iOS选择启动应用程序的初始方向。     

要回复问题请先登录注册