2012-12-29 21 views
0

我試圖把UIImagePickerController設置爲UIImagePickerControllerSourceTypeCamera(即當它允許用戶拍照時)並將其推到我自己的UINavigationalController但它不起作用(無法將UINavigationalController推到另一個UINavigationalController上)。UIImagePickerController推在我自己的UINavigationalController上?

我想知道,是否有無論如何使這個攝像頭模塊的自定義版本,很像你可以用UIImagePickerControllerSourceTypePhotoLibraryUIImagePickerController使用ALAssets?我只想不必將相機作爲模式視圖彈出,並且希望將其推到我自己的UINavigationalController上。

回答

1

您可以使用AVFoundation定製相機。

請參閱Sample AVCam瞭解如何使用AVFoundation。

0

我有同樣的問題,但我解決了這個問題。

如果你把圖片
1)從相機(在 2)從畫廊(iPad版開放作爲UIpopovercontroller &爲iPhone作爲nvigationcontroller開放)

第一組代表

同時打開作爲的UINavigationController)
@interface camera : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate,UIPopoverControllerDelegate> 

後從攝像機獲取圖像

從畫廊
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) 
     { 
      UIImagePickerController *imagePicker = 
      [[UIImagePickerController alloc] init]; 
      imagePicker.delegate = self; 
      imagePicker.sourceType = 
      UIImagePickerControllerSourceTypeCamera; 
      imagePicker.mediaTypes = [NSArray arrayWithObjects: 
             (NSString *) kUTTypeImage, 
             nil]; 

      imagePicker.allowsEditing = YES; 

      imagePicker.wantsFullScreenLayout = YES; 

      [self presentViewController:imagePicker animated:YES completion:nil]; 
      newMedia = YES; 
      iscamera = 0; 
     } 
     else 
     { 
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error to access Camera" 
                  message:@"" 
                  delegate:nil 
                cancelButtonTitle:@"OK" 
                otherButtonTitles:nil]; 
      [alert show]; 

     } 

& 獲取圖像

if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) 
    { 
     UIImagePickerController *_picker=nil; 
     if (popoverController) { 
      [popoverController dismissPopoverAnimated:NO]; 

     } 
     _picker = [[UIImagePickerController alloc] init]; 
     _picker.delegate = self;   
     _picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
     _picker.wantsFullScreenLayout = YES; 

     //[popoverController presentPopoverFromBarButtonItem:sender 
           // permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 

     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 

      [self presentViewController:_picker animated:YES completion:nil]; 


     } else 
     { 
      popoverController = [[UIPopoverController alloc] initWithContentViewController:_picker]; 
      [popoverController setDelegate:self]; 
      [popoverController presentPopoverFromRect:btn.frame 
               inView:self.view 
          permittedArrowDirections:UIPopoverArrowDirectionLeft 
              animated:YES]; 
     } 
    } 
    else 
    { 
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error access photo library" 
                 message:@"your device non support photo library" 
                 delegate:nil 
               cancelButtonTitle:@"OK" 
               otherButtonTitles:nil]; 
     [alert show]; 

    } 

兩個結果你的委託方法得到

-(void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info 
{ 

} 
1

你的主要問題是,UIImagePickerController本身就是一個UINavigationController,因此推說導航控制器上會有問題(如你已經找到)

正如Prince所說,你最好的選擇是使用AVFoundation來創建你自己的。缺點是你會(默認情況下)失去相機應用程序的好功能,如觸摸焦點,捏到縮放等,但這些都可以自己添加。

檢查出this tutorial它給你一個很好的解釋如何使用AVFoundation圖書館,並告訴你如何添加像overlay到照相機屏幕的東西。然後你可以很容易地找到谷歌/ stackoverflow如何添加像點擊重點:)

相關問題