2012-09-26 68 views
0

打開全屏模式我有一個具有酥料餅(UIPopoverController)用的若干意見推,其中之一有一個按鈕,啓動相機的iPad應用程序...查看圖像.. 。相機有不正確的屏幕位置時,從酥料餅

enter image description here

相機策動用這種方法...

- (IBAction)selectPlanImageFromCamera:(id)sender 
{ 
    [self.blockTextField resignFirstResponder]; 
    [self.levelTextField resignFirstResponder]; 
    [self.zoneNamePrefixTextField resignFirstResponder]; 
    [self.nameTextField resignFirstResponder]; 
    [self.notesTextView resignFirstResponder]; 

    imagePicker = [[UIImagePickerController alloc] init]; 
    imagePicker.allowsEditing = NO; 
    imagePicker.delegate = self; 
    imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; 
    imagePicker.modalPresentationStyle = UIModalPresentationFullScreen; 
    imagePicker.showsCameraControls = YES; 

    [self presentViewController:imagePicker animated:YES completion:^{}]; 
} 

然後我得到顯示的全屏模式攝像機視圖,所有作品期望從事實的一部分,這是定位的略低於s界限。這意味着,在底部的控制是南方20像素屏幕,並沒有在屏幕頂部的20像素的黑帶...查看圖像...

enter image description here

雖然這個程序是現在的目標在iOS6上,我之前在iOS5中獲得了同樣的效果。任何人都可以想到解決方法或修復?

很多感謝,邁克爾。

+0

您可能需要從視圖層次結構中的較高vc呈現。您可以使用委託電話或通知中心,並嘗試從更高的vc顯示。 – shawnwall

+0

謝謝你的指針'shawnwall' - 這讓我走向正確的方向。我會發布回答我的結果解決方案。 – Michael

+0

我有類似的問題...通過使用[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]解決了它; –

回答

0

從shawnwall的評論到原始問題的指針之後,我設法通過對根UIViewController執行presentViewController方法調用,然後解散並重新建立UIPopoverController拍攝照片的任何一方來解決此問題。

所以,我有我的煽動相機視圖的方法......(注意兩行結束都是新的 - 第一線駁回酥料餅和第二線呈現上的UIImagePickerController主根的UIViewController)

- (IBAction)selectPlanImageFromCamera:(id)sender 
{ 
    [self.blockTextField resignFirstResponder]; 
    [self.levelTextField resignFirstResponder]; 
    [self.zoneNamePrefixTextField resignFirstResponder]; 
    [self.nameTextField resignFirstResponder]; 
    [self.notesTextView resignFirstResponder]; 

    cameraImagePicker = [[NonRotatingUIImagePickerController alloc] init]; 
    cameraImagePicker.allowsEditing = NO; 
    cameraImagePicker.delegate = self; 
    cameraImagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; 
    cameraImagePicker.modalPresentationStyle = UIModalPresentationFullScreen; 
    cameraImagePicker.showsCameraControls = YES; 

    [mainCanvasViewController.sitePopoverController dismissPopoverAnimated:YES]; 
    [mainCanvasViewController presentViewController:cameraImagePicker animated:YES completion:^{}]; 
} 

我再重新出現在任何地方酥料餅,我解聘的UIImagePickerController - 在這種情況下,在didFinishPickingMediaWithInfo的委託方法(如在上面詳述的相同的UIViewController)...

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info 
{ 
    if ([info objectForKey:UIImagePickerControllerMediaType] == (NSString *)kUTTypeImage) 
    { 
     ... // image handling 
    } 

    [picker dismissViewControllerAnimated:YES completion:^{}]; 

    UIBarButtonItem *tappedButton = mainCanvasViewController.navigationItem.leftBarButtonItem; 
    [mainCanvasViewController.sitePopoverController presentPopoverFromBarButtonItem:tappedButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 
} 

這工作得很好 - 克洛斯當相機在屏幕底部動畫時,彈出窗口重新出現時,相機視圖的重新呈現和彈出窗口的重新呈現可能會更整齊一些,如果在相機過渡之後出現彈出窗口,看起來會更好,但對於我目前不是一個大問題。

希望這有助於人誰願意從UIPopoverController打開全屏攝像頭的UIImagePickerController。

親切的問候, 邁克爾。

1

我們懷疑這是某種聯繫的狀態欄的高度,20px。我們的猜測是正確的,下面的代碼爲我們隱藏了狀態欄,而UIIMagePickerController顯示。

UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; 
imagePicker.delegate = self; 
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera; 
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage,nil]; 
imagePicker.allowsEditing = NO; 

if (IS_IPAD) 
{     
    imagePicker.modalPresentationStyle = UIModalPresentationFullScreen; 
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone]; 

    [self presentViewController:imagePicker animated:YES completion:nil]; 
} 

有人可能有以下代碼添加到每個以下代表組成: - imagePickerControllerDidCanceldidFinishPickingMediaWithInfofinishedSavingWithError

if (IS_IPAD) 
{ 
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone]; 
} 
0

嘗試

cameraImagePicker.modalPresentationStyle = UIModalPresentationFullScreen;

這將告訴實例的UIImagePickerController呈現樣式和修復這個bug。