在我的应用程序中,我执行以下序列:
1)我使用设备相机拍摄图像
2)在didFinishPickingMediaWithInfo
我收回图片时,我会关闭UIImagePickerController
并提出viewController
,就像这样
[self dismissViewControllerAnimated:YES completion:^(void){
[self presentNewViewController];
}];
presentNewViewcontroller看起来像这样
- (void) presentNewViewController {
newViewController* newVC = [[newViewController alloc]init];
[newVC setImage: selectedImage]; //selected Image comes from didFinishPickingMediaWithInfo
[self presentViewController:newVC animated:YES completion:nil];
}
这意味着在UIImagePickerController
被解雇后我立即提出一个新的控制器。
此操作很好地在模拟器上运行,但在设备上会导致应用程序滞后。首先,我需要等待2-3秒,然后新的viewController
开始出现,即便如此,它的动画也会变得缓慢而且不是很流畅。
起初我认为所选图片太大了,但后来我使用UIImageJPEGRepresentation
对其进行了压缩,但结果没有改变。
有谁知道为什么会这样?