IOS仅允许纵向某些视图和其他视图上的横向

时间:2014-01-20 21:40:45

标签: ios iphone objective-c orientation screen-orientation

一直试图弄清楚这一点,SO中的一些答案看起来很有前途但没有奏效。所以希望有人可以提供帮助。

我在IOS 7上运行了一个应用程序(向后兼容IOS 5)。大多数视图应该只是肖像,少数允许横向模式。

但是......现在我的工作很重要,我无法通过IOS阻止视图进入横向模式。

主视图是UIViewController类型。并实现下面的所有方法(是的尝试了一切:)

#pragma mark Orientation Methods

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (BOOL)shouldAutorotate
{
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}



- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)w {

    return (NSUInteger)[application supportedInterfaceOrientationsForWindow:w] | (1<<UIInterfaceOrientationPortrait);

}

- (NSUInteger)application:(UIApplication *)application preferredInterfaceOrientationForPresentation:(UIWindow *)w {

    return (NSUInteger)[application supportedInterfaceOrientationsForWindow:w] | (1<<UIInterfaceOrientationPortrait);

}

但它仍然允许用户将视图更改为横向模式。有人可以帮忙吗?

0 个答案:

没有答案