在 UIImagepickercontroller ios 中单击使用按钮后无法点击任何地方
Posted
技术标签:
【中文标题】在 UIImagepickercontroller ios 中单击使用按钮后无法点击任何地方【英文标题】:Can not tap anywhere after click Use button in UIImagepickercontroller ios 【发布时间】:2014-01-22 08:36:35 【问题描述】:我有一个问题,录制视频后,我点击使用按钮将此视频保存到库,但保存完成后,我无法点击播放按钮或重拍按钮。这是我的代码:
-(void)actionLaunchAppCamera
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
UIImagePickerController * imagePickerController = [[UIImagePickerController alloc] init];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
imagePickerController.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.showsCameraControls = YES;
imagePickerController.allowsEditing = YES;
imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
imagePickerController.delegate = self;
imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear;
[self presentModalViewController:imagePickerController animated:YES];
//[imagePickerController release];
保存拍摄的图像
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
NSURL *recordedVideoURL= [info objectForKey:UIImagePickerControllerMediaURL];
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:recordedVideoURL])
[library writeVideoAtPathToSavedPhotosAlbum:recordedVideoURL
completionBlock:^(NSURL *assetURL, NSError *error)
[library assetForURL:assetURL resultBlock:^(ALAsset *asset)
NSDate* date = [asset valueForProperty:ALAssetPropertyDate];
NSLog(@"Date Time Modify %@",date);
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat: @"dd.MM.yyyy HH:mm:ss"];
NSString* CurrentDateStamp = [formatter stringFromDate:date];
NSLog(@"NameVideo %@",asset.defaultRepresentation.filename);
NSLog(@"DateModify %@",CurrentDateStamp);
NSLog(@"Size: %lld", asset.defaultRepresentation.size);
failureBlock:nil];
actionSheetUpload= [[UIActionSheet alloc] initWithTitle:@"Do you want to upload this video?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Upload" otherButtonTitles:nil];
actionSheetUpload.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[actionSheetUpload showInView:[UIApplication sharedApplication].keyWindow];
[actionSheetUpload release];
];
[library release];
有什么想法吗?提前致谢
【问题讨论】:
那么要玩的代码在哪里..?您只是保存视频,之后需要播放视频 保存视频后,我会将此视频上传到服务器。我更新了问题中的代码。 那你应该用播放器来玩吧? 【参考方案1】:也许您不会使用 - (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^)(void))completion
关闭选择器
【讨论】:
【参考方案2】:该代码非常适合保存视频,如果您想播放它。然后你需要使用播放器来播放它。
例如:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
NSURL *recordedVideoURL= [info objectForKey:UIImagePickerControllerMediaURL];
.// Save Your Stuff
.
.
MPMoviePlayerController *movieplayer =[[MPMoviePlayerController alloc] initWithContentURL: recordedVideoURL];
[[movieplayer view] setFrame:
[self.view bounds]];
[self.view addSubview:
[movieplayer view]];
[movieplayer play];
编辑:
对于上传视频,根据您的代码:
声明NSURL *recordedVideoURL;
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
//NSLog(@"but ind %d", buttonIndex);
if (buttonIndex == uploadBTnIndex)
NSData *videoData = [NSData dataWithContentsOfURL:recordedVideoURL];
//Use this NSData to upload, So what else your problem to upload using web Services ?
【讨论】:
谢谢,但我不需要播放视频。我只需要将它上传到服务器。 那是什么问题,你要求我在完成(保存)后做上传代码。 我的问题是点击Use video后,它会显示Actionsheet Uploading,然后我点击Actionsheet上的Cancel来支持UIImagePickercontroller,但是UIImagePickerController似乎无法点击任何按钮。以上是关于在 UIImagepickercontroller ios 中单击使用按钮后无法点击任何地方的主要内容,如果未能解决你的问题,请参考以下文章
在 iOS 7 中呈现 UIImagePickerController 的问题
如何在 iPad 上关闭 UIImagePickerController
仅在横向 UIImagePickerController 中显示CameraControls
UIImagePickerController 在 iOS 11 上泄漏