Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 导航转换口吃_Iphone_Ios_Cocoa Touch_Uinavigationcontroller_Uiimagepickercontroller - Fatal编程技术网

Iphone 导航转换口吃

Iphone 导航转换口吃,iphone,ios,cocoa-touch,uinavigationcontroller,uiimagepickercontroller,Iphone,Ios,Cocoa Touch,Uinavigationcontroller,Uiimagepickercontroller,我有一个UIImagePickerController,允许用户拍摄照片,然后将其存储在UIImageView中,如下所示: - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [self dismissModalViewControllerAnimated:YES]; self.photoImage

我有一个UIImagePickerController,允许用户拍摄照片,然后将其存储在UIImageView中,如下所示:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [self dismissModalViewControllerAnimated:YES];
    self.photoImageView.image = nil;
    [self.activityIndicatorView startAnimating];

    dispatch_async(dispatch_get_global_queue(0, 0), ^
    {
        UIImage *image = [[info objectForKey:@"UIImagePickerControllerOriginalImage"] retain];
        dispatch_async(dispatch_get_main_queue(), ^
        {
            self.photoImageView.image = image;
            [self.activityIndicatorView stopAnimating];
            self.rightButton.enabled = YES;
            [image release];
        });

    });
}
当我将此图像作为参数传递给下一个被推到导航堆栈上的UIViewController时,UINavigation转换会结巴,并且非常不稳定/丑陋。我已经做了一个配置文件,我的代码中没有任何东西是真正突出的

我知道用相机拍摄的照片可能很大,但如果我只是传递一个引用,为什么这会对任何事情产生影响?我的照片库中有我拍摄的照片,当我从中选择它们并将它们传递到下一个过渡时,一切都很顺利


有人知道这是什么原因吗?

可能是因为在将新的UIViewController推送到导航堆栈时发生了调整大小的过程

假设从iPhone4相机拍摄的照片分辨率为2592 x 1936http://stackoverflow.com/questions/3270202/what-is-resolution-of-photo-taken-by-iphone-4-camera. 您的UIImageView的大小为400 x 300px,然后将在视图中进行调整大小的过程,这可能会使您的转换出现口吃

有几种解决方法:

在ViewDidDisplay中显示图像,只需保留对图像的引用并将其设置为ViewDidDisplay中的imageView.image即可

在显示图片之前,先调整图片大小,比如说调整到640 x 960


谢谢,你们知道我刚刚发现了这个:它准确地描述了你们正在谈论的调整大小。我的问题是,我可以调用什么代码来确定图像的正确大小?如果有视网膜的话,应该是纵向屏幕边界*2吗?调整大小的正确大小取决于UIImageView大小本身以及你想要的纵横比(aspect fit、aspect fill等)。我建议使用640*960,因为这是屏幕的视网膜分辨率,而不是iPhone 5的分辨率,希望它能小到足以让过渡期口吃消失。如果您想将调整大小的版本保存到将显示全屏照片的相机卷库中,该分辨率也会起作用。对于我来说,我正在imageView中缩放该图像,因此我想屏幕大小可以做到这一点。你介意把这个链接放在2的答案中吗?这里有一篇很好的博客文章解释了如何在iOS中调整图像大小,希望能有所帮助