-1

我创建了一个应用程序,它从相机中选择图像,并在 didFinishPickingMediaWithInfo 上将其传递给另一个视图并加载此视图。我认为代码还可以,但显示第二个视图需要大约 15-20 秒。所以请让我知道如何解决这个加载问题。

我的代码块是:

-(void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [[picker parentViewController] dismissModalViewControllerAnimated:YES];

    [NSThread detachNewThreadSelector:@selector(switchToSecondView:) toTarget:self withObject:info];
}

-(void) switchToSecondView:(NSDictionary *)info
{
    UIImage *image = [info
              objectForKey:UIImagePickerControllerOriginalImage];

    secController =[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
    secController.myimage = image;

    AppDelegate *appDelegate=(AppDelegate *)[[UIApplication sharedApplication] delegate];
    [appDelegate.navController pushViewController:secController animated:NO];
}

谢谢, Laxmilal Menaria

4

1 回答 1

0

UiKit 仅在主线程上 [压倒性地] 安全使用。您的工作switchToSecindView:是在后台线程上进行的。因此行为是未定义的。

可能发生的情况是 UIKit 无法注意到您的更改,直到它碰巧在进行其他处理。

于 2012-12-03T08:07:59.387 回答