【发布时间】:2010-12-01 05:27:57
【问题描述】:
所以我创建了一个完整的应用程序,它按照我的设想完美运行。创建了一个使用 UIImages 的更新,并且仅在 iOS 4 及更高版本上也能完美运行。出于某种原因,完全相同的代码在 3.0 上将无法正常工作。由于最初的应用程序在最小操作系统为 3 的商店中,我不想因为我的一些愚蠢的错误而切断我的用户群。我没有做任何新的事情,所以它应该都是向后兼容的。
基本上,该应用会从相机或相册中选择一张图像,然后将其保存,然后将图像显示在屏幕上。当您进入下一个屏幕时,它会从磁盘中提取图像文件并将其显示在下一个屏幕的图像视图中。同样,在 iOS4 及更高版本上运行良好。
在旧版本的 xcode 上使用 3.0 sim,它的功能就不同了。我知道 allowImageEditing 更改为 allowEditing,所以我允许这样做,但根据文档显示的其他所有内容都应该适用于 iOS 3 及更高版本。
下面是我去相册并返回。
-(IBAction) getPhotoFromAlbum {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if (editingSwitch.on) {
#ifdef __IPHONE_3_0
picker.allowsImageEditing = YES;
#else
picker.allowsEditing = YES;
#endif
} else if (!editingSwitch.on) {
#ifdef __IPHONE_3_0
picker.allowsImageEditing = NO;
#else
picker.allowsEditing = NO;
#endif
}
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:picker animated:YES];
[picker release];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
UIImage *image = nil;
if (editingSwitch.on) {
image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:isImageEdited];
} else if (!editingSwitch.on) {
image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:isImageEdited];
}
imageView.image = [self imageWithImage:image];
imageView.hidden = NO;
buttonPreview.hidden = YES;
[NSThread detachNewThreadSelector:@selector(myThreadSavingImage) toTarget:self withObject:nil];
[activitySaving startAnimating];
当我调试时,从选择器返回的信息似乎只有 1 个键。当它设置图像时,图像是空白的。基本上没有图像会返回,如果在极少数情况下会返回,例如当我编辑图片而不只是使用原始图像时,它不会显示在下一页上。
希望每个人都可以在应用程序完成时提供帮助,除了这个 3.0 问题和令人沮丧的问题,因为我想尽快发布它。
【问题讨论】:
标签: iphone ios uiimageview uiimagepickercontroller backwards-compatibility