2012-08-30 96 views
0

我想從庫中選擇視頻。這是我的代碼。如何從iPhone庫中獲取視頻

picker1 = [[UIImagePickerController alloc] init]; 
picker1.delegate = self; 
NSArray *mediaTypesAllowed = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; 

picker1.sourceType=UIImagePickerControllerSourceTypeSavedPhotosAlbum; 
picker1.mediaTypes = mediaTypesAllowed; 
[self presentModalViewController:picker1 animated:YES]; 

}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{ 
[picker dismissModalViewControllerAnimated:YES]; 
if ([picker isEqual:picker1]) 
{ 
    NSString *mediaType = [info valueForKey:UIImagePickerControllerMediaType]; 
    if([mediaType isEqualToString:@"public.movie"]){ 
     NSLog(@"%@",info); 
    } 
} 

問題是,當我從庫中選擇視頻,模擬器得到忌用。即使代表方法didFinishPickingMediaWithInfo不呼叫

在此先感謝。

+0

你的代碼看起來不錯...嘗試刪除'NSLog'線或評論它..並且還寫picker1代替當您關閉它時.. – Maulik

+1

請參閱[Accessing_the_iOS_5_iPhone_Camera_and_Photo_Library](http://www.techotopia.com/index.php/Accessing_the_iOS_5_iPhone_Camera_and_Photo_Library)鏈接並檢查您的代碼。 –

回答

0

嘗試這個

myImagePickerController.mediaTypes = 
[[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil]; 

或引用此 UIImagePickerControllerMediaType 希望這有助於ü