iOS 8 – 在设置关键窗口或关闭窗口后立即呈现视图控制器时,会出现毛刺,并显示另一个窗口

前端之家收集整理的这篇文章主要介绍了iOS 8 – 在设置关键窗口或关闭窗口后立即呈现视图控制器时,会出现毛刺,并显示另一个窗口前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
自从在iOS 8上测试我的应用程序以来,我发现一个关于视图控制器初始化和演示的工作真的很慢.

我以前在iOS 6& 7:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    ....

    [self.window setRootViewController:_rootController];
    [self.window makeKeyAndVisible];

    // Conditions

    if (#first launch condition#) {
        // quite small controller containing Welcome showcase
        WelcomeViewController *w = ....
        [_rootViewController presentViewController:w animated:NO];
    }

    else if (#last opened item condition#) {
        // pretty big container,root view controller contains
        // a grid view which opens Item detail container the same way
        ItemDetailController *item = ....
        [_rootViewController presentViewController:item animated:NO];
    }

}

这成为一个非常迟钝的地狱与iOS 8.根视图控制器现在出现可见的0.5-1秒,然后立即重绘屏幕与呈现.此外,演示的缓慢开始导致不平衡调用开始/结束外观转换_rootViewController警告.

初始的快速提示是通过调用另一个函数来移动这两个条件,并使用零延迟调用它,以便在下一个主运行循环中进行处理:

[self performSelector:@selector(postAppFinishedPresentation) withObject:nil afterDelay:0];

或类似的东西.这解决了不平衡的调用问题,但是视觉差距(rootviewcontroller,差距,呈现一个)变得(显然)更大.

当你打电话时,演示的缓慢也很明显:

// Example: Delegate caught finished Sign In dialog,//          dismiss it and instantly switch to Profile controller

-(void)signInViewControllerDidFinishedSuccessfully
{
    [self dismissViewControllerAnimated:NO completion:^{
         UserProfileViewController *userProfile = ...
         [self presentViewController:userProfile animated:NO];
    }];
}

这应该是完全公平的代码,用于在iOS 7上执行直接转换,而不会看到父视图控制器的可见轻松.现在,同样的事情 – 父进程在转换期间轻弹,即使它们都没有动画处理.

有人面对这个问题吗?任何解决方案?我想要解决这个问题,而无需使用UIWindows做一些热闹的魔法,我需要完美的传输.

解决方法

我不知道这个要求是限制有root视图控制器,并在那里提供任何东西.

但是根据你的代码,这是有欢迎的视图控制器的事情,我认为在这种情况下,这个逻辑更有用.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Conditions

    if (#first launch condition#) {
        // quite small controller containing Welcome showcase
        WelcomeViewController *w = ....

        //It can be navigation or tab bar controller which have "w" as rootviewcontroller
        [self.window setRootViewController:w];
    }

    else if (#last opened item condition#) {
        // pretty big container,root view controller contains
        // a grid view which opens Item detail container the same way
        ItemDetailController *item = ....
        //It can be navigation or tab bar controller which have "item" as rootviewcontroller
        [self.window setRootViewController:item];
    }

    [self.window makeKeyAndVisible];

}
原文链接:https://www.f2er.com/iOS/336854.html

猜你在找的iOS相关文章