【问题标题】:Simultaneous animations block each other同步动画相互阻挡
【发布时间】:2011-09-19 16:31:25
【问题描述】:

我们的 iPad 应用程序有一个主 UIViewController 的视图,其中包含几个具有自己任务的子视图,它们包含 uitableviews、图像画廊、图形和代码。我们还确保每个子视图都作为自己的控制器类来管理动画和用户交互。

问题是动画相互阻塞,每次我们与 tableView 交互时,ticker 和 gallery(也有自动动画)冻结。

对于同步动画,我们可以尝试什么方法? 我们应该尝试直接使用带有核心动画的图层还是在同一个动画块中执行所有动画?

谢谢。

【问题讨论】:

    标签: ios multithreading animation core-animation


    【解决方案1】:

    这里有一些有用的代码:

    // We schedule a timer for a desired 30fps animation rate.
    // In performAnimation: we determine exactly
    // how much time has elapsed and animate accordingly.
    timer = [[NSTimer scheduledTimerWithTimeInterval:(1.0/30.0) target:self selector:@selector(performAnimation:) userInfo:nil repeats:YES] retain];
    
    // The next two lines make sure that animation will continue to occur
    // while modal panels are displayed and while event tracking is taking
    // place (for example, while a slider is being dragged).
    [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSModalPanelRunLoopMode];
    [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSEventTrackingRunLoopMode]; 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-04
      • 1970-01-01
      • 1970-01-01
      • 2014-11-10
      相关资源
      最近更新 更多