2

ビデオカメラを開くためにポップオーバーコントローラーを使用しているアプリケーションを作成しています。そのコントロールには、ビデオ録画を開始するために使用されるボタンがあります。そのボタンを削除して、そのポップオーバー コントローラーの外側のボタンに同じ機能を与えることは可能ですか?

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]; 
 }}
4

1 に答える 1

2
-(IBAction)MyNewButton
{  
    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];


        [self.view addsubview:videoRecorder.view];  
        [videoRecorder release];


}

これを試して

于 2012-04-27T07:02:49.583 に答える