相关疑难解决方法(0)

我们如何在iOS 8中指定应用程序方向?

在iOS 7中我们说:

// ViewController1:

-(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}

-(BOOL)shouldAutorotate {
    return YES;
}

// ViewController2, presented by modal segue from button in ViewController1

-(NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

-(BOOL)shouldAutorotate {
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

结果是app在视图控制器1中以横向显示并且在视图控制器2中以纵向显示.

该代码在iOS 7中运行良好,包括Xcode 6中的iOS 7模拟器.但它不再适用于iOS 8.有两个问题:

  • 视图控制器1的视图以横向显示,但模拟器不会自动旋转(可能只是模拟器错误)和(这是非常重要的部分)视图不会自动调整大小,因此它对于屏幕来说太窄了(右边有一个很大的黑色区域.

  • View Controller 2的视图与View Controller 1的视图(横向,而不是纵向)的方向相同.

因此,视图控制器视图不会自动调整大小以填充屏幕,并且不会遵循呈现的视图控制器支持的方向.

那么我们现在应该如何做呢?它与特质集合有关吗?首选内容大小?手动设置状态栏方向?

ios8

17
推荐指数
1
解决办法
2万
查看次数

iOS 7+关闭模态视图控制器和强制纵向方向

我有一个UINavigationController作为我在iOS 7和iOS 8上的UIWindow的根视图控制器.从它的一个视图控制器,我提出了一个具有交叉溶解演示风格的全屏模态视图控制器.这个模态视图控制器应该能够旋转到所有方向,并且它工作正常.

问题是当设备以横向方向保持并且模态视图控制器被解除时.呈现模态的视图控制器仅支持纵向方向,并且我已确认UIInterfaceOrientationMaskPortrait返回到-application:supportedInterfaceOrientationsForWindow:.-shouldAutorotate也返回YES.然而,在解除模态之后,呈现视图控制器的方向仍然是风景.在允许模态采取设备方向的同时,如何强制它保持纵向方向?我的代码如下:

应用代表:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
        UINavigationController *navigationController = (UINavigationController *)self.deckController.centerController;
        NSArray *viewControllers = [navigationController viewControllers];
        UIViewController *top = [viewControllers lastObject];

        if (top && [top presentedViewController]) {
            UIViewController *presented = [top presentedViewController];
            if ([presented respondsToSelector:@selector(isDismissing)] && ![(id)presented isDismissing]) {
                top = presented;
            }
        }

        return [top supportedInterfaceOrientations];
    }

    return (UIInterfaceOrientationMaskLandscapeLeft|UIInterfaceOrientationMaskLandscapeRight);
}
Run Code Online (Sandbox Code Playgroud)

呈现视图控制器:

- (BOOL)shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
} …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c rotation screen-orientation ios

13
推荐指数
2
解决办法
6228
查看次数

仅在一个ViewController中旋转

我正在尝试旋转一个视图,而所有其他视图(5)都固定为纵向.原因是在一个视图中我希望用户观看他之前保存的图片.我想这是可能的,但到目前为止我无法弄清楚如何实现这一目标.任何人都可以帮忙或给我一个暗示吗?我正在使用在iOS8上运行的Swift编程

xcode rotation uiviewcontroller ios swift

11
推荐指数
5
解决办法
1万
查看次数

iOS8 - 阻止在呈现viewController时旋转

我们有一个带有tableView的MainViewController,它提供了一个新的modalViewController.

MainViewController仅限于纵向,modalViewController可以旋转.

问题出在iOS8中,当modalViewController旋转时,调用MainViewcontroller中iOS8中的旋转回调方法 - - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator

因此,UITableView正在重新加载其数据,这是我们不想要的行为.

我们可以阻止iOS 8的这个功能,而不是旋转呈现的UIViewController吗?

rotation uitableview modalviewcontroller ios ios8

11
推荐指数
1
解决办法
3008
查看次数

在iOS6中,当在堆栈上推送时,麻烦强制ViewController到某个interfaceOrientation

我有以下视图控制器设置:

viewController1可以自由旋转到除了纵向颠倒之外的任何方向.

viewController2被推到viewController1的顶部,我希望它与viewController1的方向相同,我希望它不能旋转.

viewController3被推到viewController2的顶部.我希望viewController3处于纵向模式.

我在iOS6中尝试完成此操作时遇到了很多问题(尚未在iOS5中尝试过).首先,我已经创建了自己的导航控制器并在其中添加了以下内容:

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [self.topViewController preferredInterfaceOrientationForPresentation];
}

- (NSUInteger)supportedInterfaceOrientations
{
    return [self.topViewController supportedInterfaceOrientations];
}

- (BOOL) shouldAutorotate
{
    return [self.topViewController shouldAutorotate];
}
Run Code Online (Sandbox Code Playgroud)

我已经尝试了很多这些东西的不同组合来了解情况.我正在努力的主要是强迫vc3呈现为肖像,如果vc2在风景中.任何帮助,将不胜感激.

iphone cocoa-touch uiviewcontroller ios

8
推荐指数
2
解决办法
6623
查看次数

支持多接口但在主屏幕中具有单一界面,在iOS8 + iPhone中不起作用

我有如下的视图结构.

HomeView(Support only portrait mode)
 |
 |
 V
View1(Support all orientation)
 |
 |
 V
View2(Support all orientation)
Run Code Online (Sandbox Code Playgroud)

问题:
当我coming back from View2(Landscape mode)HomeView调用popToRootViewController的方法,它没有调用supportedInterfaceOrientationsForWindow的方法App_Delegate并显示 在HomeViewlandscape mode.

图片:

在此输入图像描述

注意:
当我从View1(横向模式)返回到HomeView时,通过调用popToRootViewController方法调用supportedInterfaceOrientationsForWindow并且所有工作都很好,同样的事情不会发生.
如果我在iOS7中使用XCode6运行app,一切都很棒.

I read below question but it did not help me.
解雇模态视图控制器时如何保持显示视图控制器的方向?

在上面的链接mattiOS8 stop support for friezing orientation,但我没有找到它,apple document 如果你有任何reference link关于这个改变请分享.

问题:
1]为什么委托方法supportedInterfaceOrientationsForWindow不调用.
2]是否可以使一个视图具有支持单一方向,而所有其他视图将支持所有方向.

谢谢

iphone orientation uiviewcontroller xcode6 ios8

7
推荐指数
1
解决办法
3388
查看次数