2012-04-27 11 views
1

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

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

答えて

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


} 

をビデオカメラを開くためのコードは、あなたの質問は何ですか?この

+2

を試してみてくださいですか –

+1

実際の要件は何ですか? –

+0

カスタムUIImagePickerが必要ですか?それは...ですか? – NSCry

関連する問題