【问题标题】:Image Loading in Thread Makes Navigation Transition Choppy线程中的图像加载使导航过渡断断续续
【发布时间】:2011-10-27 20:55:19
【问题描述】:

我有一个应用程序,用户单击照片缩略图会触发下一个视图控制器被推送到导航堆栈上,该堆栈负责显示更大版本的图片。当按下照片缩略图按钮时,我将照片 alasset 引用发送到下一个视图控制器,该视图控制器在其 viewDidLoad 方法中加载它,如下所示:

dispatch_async(dispatch_get_main_queue(), 
^{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    UIImageView *tempMyImageView = [[UIImageView alloc] initWithImage: [UIImage imageWithCGImage:[[[self myAsset] defaultRepresentation] fullScreenImage]]];
    [self setMyImageView: tempMyImageView];
    [myViewContainer addSubview: [self myImageView]]; 
    [tempMyImageView release];
    [pool drain];
});

似乎一切正常,除了当我发送一张大图像(比如我从相机拍摄的一张)时,导航过渡不稳定。有谁知道如何解决这个问题?

【问题讨论】:

    标签: iphone objective-c ios cocoa-touch uiimage


    【解决方案1】:

    您可以尝试在转换完成后仅加载图像。

    另外值得注意的是,您实际上并没有在新线程中执行此操作,因为您指定了主队列。这并不是一个好主意,因为您不想在另一个线程上执行 UI 代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-04-10
      • 1970-01-01
      • 2013-01-22
      • 1970-01-01
      • 2021-10-05
      相关资源
      最近更新 更多