开发者

iOS 4.2 camera and album problem

开发者 https://www.devze.com 2023-01-28 21:38 出处:网络
for some reason the same code I used to access the camera and photo album that used to work with previous iOS is not working. Whenever I open the camera application or the photo album the app crashes,

for some reason the same code I used to access the camera and photo album that used to work with previous iOS is not working. Whenever I open the camera application or the photo album the app crashes, and nothing appears on the crash log. I tested it for iOS 3.0 to 4.1 and it worked fine. Did this happen to anyone? is it a bug? It doesn't even get to the imagePickerController me开发者_运维百科thod, it crashes as soon as it loads the camera or album.

The code I use is this:

#pragma mark Photo methods

- (void) getNewPhoto {
 UIImagePickerController * picker = [[UIImagePickerController alloc] init];
 picker.delegate = self;
 picker.sourceType = UIImagePickerControllerSourceTypeCamera;
 [self presentModalViewController:picker animated:YES];
}

- (void)loadPhotoFromLibrary {
 UIImagePickerController * picker = [[UIImagePickerController alloc] init];
 picker.delegate = self;
 picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
 [self presentModalViewController:picker animated:YES];
}

#pragma mark ImagePickerController methods

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
 [picker dismissModalViewControllerAnimated:NO];
 selectedImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}

Thanks!


Hope ur issue got resolved, if not try this...

As far as i know, UIImagePickerController does not work for iPad...it cannot present any view controller, so try with UIPopoverController (for iPad)...i have used the same thing and it really worked well....

0

精彩评论

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