0

我有一个应用程序,我想用它从照片库中选择照片或视频并将它们上传到服务器。这适用于 ios 4。代码如下:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{

image_selected = FALSE;
video_selected = FALSE;  
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage,(NSString *)kUTTypeMovie, nil];

NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
    image_selected = TRUE;
    imageFrame = [info objectForKey:UIImagePickerControllerOriginalImage];
    NSLog(@"image1 has %@", imageFrame);
    [image setImage:imageFrame];
}else if ([mediaType isEqualToString:(NSString *)kUTTypeMovie]) {
    video_selected = TRUE;
    videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
    NSLog(@"video has %@", videoURL);
    MPMoviePlayerController *mp = [[MPMoviePlayerController alloc]initWithContentURL:videoURL];
    videoFrame = [[mp thumbnailImageAtTime:0.0 timeOption:MPMovieTimeOptionNearestKeyFrame]retain];
    [image setImage:videoFrame];
    [mp release];
}
  [[picker parentViewController] dismissModalViewControllerAnimated:YES];
}

但是,这在 ios 5(模拟器或设备)中不起作用。The application freezes as and when the choose button in photo library is selected.

非常需要这方面的任何帮助。

4

1 回答 1

1
[picker dismissModalViewControllerAnimated:YES];
于 2012-06-04T12:03:22.567 回答