gpt4 book ai didi

iphone - 如何在 iPhone 中使用移动和缩放 UIImagePickerController?

转载 作者:可可西里 更新时间:2023-11-01 05:46:52 26 4
gpt4 key购买 nike

我是 iPhone 开发新手。我正在使用图像选取器 Controller ,我想在其中移动和缩放从照片库中选取的图像,因此我启用了 allowsediting = yes

我的选择器确实完成了方法:

 - (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Access the uncropped image from info dictionary

UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
self.imgForDisplay.image=[self scaleAndRotateImage:image];
self.imagePicker.allowsEditing = YES;


ImageDetailsViewController *imageDetailsVC = [[ImageDetailsViewController alloc] init];
imageDetailsVC.imagedisplay.image = self.imgForDisplay.image;
[picker pushViewController:imageDetailsVC animated:YES];



//[picker dismissModalViewControllerAnimated:YES];

}

然后我将另一个 View Controller 推送到我想要显示所选图像的位置。

这里我有两个问题:

1) 当我选择图像时,它导航到另一个没有“移动和缩放”屏幕的 View ,但图像现在在导航时显示在 ImageDetailsViewController 中。

2) 当我再次返回并选择另一张图片时,它现在显示“移动和缩放”屏幕。当我点击选择按钮时,它只是显示一个没有导航栏的白屏。

有什么方法可以设置选择按钮的 Action 吗?

最佳答案

我也遇到了同样的问题,我通过使用代码解决了它,通过这个它会很有用。

 - (void)imagePickerController:(UIImagePickerController *)picker  
didFinishPickingMediaWithInfo:(NSDictionary *)info {
self.lastChosenMediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([lastChosenMediaType isEqual:(NSString *)kUTTypeImage]) {
UIImage *chosenImage = [info objectForKey:UIImagePickerControllerEditedImage];
UIImage *shrunkenImage = shrinkImage(chosenImage, imageFrame.size);
self.image = shrunkenImage;
} else if ([lastChosenMediaType isEqual:(NSString *)kUTTypeMovie]) {
self.movieURL = [info objectForKey:UIImagePickerControllerMediaURL];
}

ImageSelectionView *imageSelectionVC = [[ImageSelectionView alloc] init];
imageSelectionVC.theImage = image;
[picker pushViewController:imageSelectionVC animated:YES];
imageSelectionVC.dismissDelegate =self;


// [picker dismissModalViewControllerAnimated:YES];
}

'

-(void)updateDisplay { 
if ([lastChosenMediaType isEqual:(NSString *)kUTTypeImage]) {
imageView.image = image;
imageView.hidden = NO;
moviePlayerController.view.hidden = YES;
} else if ([lastChosenMediaType isEqual:(NSString *)kUTTypeMovie]) {
[self.moviePlayerController.view removeFromSuperview];
self.moviePlayerController = [[MPMoviePlayerController alloc]
initWithContentURL:movieURL] ;
moviePlayerController.view.frame = imageFrame;
moviePlayerController.view.clipsToBounds = YES;
[self.view addSubview:moviePlayerController.view];
imageView.hidden = YES;
}
}

关于iphone - 如何在 iPhone 中使用移动和缩放 UIImagePickerController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10450177/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com