我正在创建一个应用程序,在该应用程序中我使用 popover 控制器打开摄像机。该控件提供了一个用于开始视频录制的按钮。现在是否可以删除该按钮并为该弹出框控制器外部的按钮提供相同的功能?
这是在popovercontroller中打开摄像机的代码
-(IBAction)openVideoCameraPopOver:(id)sender
{
if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
{
@try
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *videoRecorder = [[UIImagePickerController alloc]init];
NSArray *sourceTypes = [UIImagePickerController availableMediaTypesForSourceType:videoRecorder.sourceType];
if (![sourceTypes containsObject:(NSString*)kUTTypeMovie] )
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
message:@"Device Not Supported for video Recording." delegate:self
cancelButtonTitle:@"Yes"
otherButtonTitles:@"No",nil];
[alert show];
[alert release];
return;
}
videoRecorder.sourceType = UIImagePickerControllerSourceTypeCamera;
videoRecorder.mediaTypes = [NSArray arrayWithObject:(NSString*)kUTTypeMovie];
videoRecorder.videoQuality = UIImagePickerControllerQualityTypeLow;
videoRecorder.videoMaximumDuration = 120;
videoRecorder.delegate = self;
videoRecorder.contentSizeForViewInPopover=CGSizeMake(25,25);
popoverCamera= [[UIPopoverController alloc]
initWithContentViewController:videoRecorder];
[popoverCamera presentPopoverFromRect:CGRectMake(cropRectangleButton.frame.origin.x,cropRectangleButton.frame.origin.y,0,0) inView:innerview permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
[self presentModalViewController:videoRecorder animated:YES];
[videoRecorder release];
}
}
@catch (NSException *exception)
{
}
}
else
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Take picture " delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Camera", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
actionSheet.alpha=0.90;
actionSheet.tag = 1;
[actionSheet showInView:self.view];
[actionSheet release];
}}