开发者

UIImagePickerController not working for iOS 3 yet works for iOS 4...backwards compatibility issue

So I created an entire app and it works flawlessly the way I envisioned. Created an update that uses UIImages, and that works perfectly as well ONLY ON iOS 4 and above. For some reason the exact same code will not work the same on 3.0. Since the original app is on the store at min OS being 3, I do not want to just cut off my user base because of some silly mistake on my part. I'm not doing anything new, so it should all be backwards compatible.

Basically the app takes an image chosen from either the camera or the photo album and then saves it, and displays the image on the screen. When you go to the next s开发者_如何学编程creen it pulls the image file off the disk and displays it in the image view on the next screen. Again, works fine on iOS4 and above.

Using the 3.0 sim on an older version of xcode, it just will not function the same way. I know allowImageEditing changed to allowEditing, so I allowed for that, but everything else it seems according to the docs, should work on iOS 3 and above.

Below is my going to photo album and returning.

-(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];

When I debug, it seems the info that is coming back from the picker only has 1 key. When it sets the image, the image is blank. Basically no image ever comes back and if for some rare occasion it does, like when I edit the picture and not just use the original, it does not show up on the next page.

Hopefully everyone can help as the app is finished besides this 3.0 issue and its frustrating as I want to get it out soon.


Turns out the answer is that it was not working on the simulator due to the updates to the xcode program. When actually installed onto a 3.0 device, the code worked perfectly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜