2011-08-28 4 views
9

다음 기능을 사용하여 UIActionSheet의 결과에 따라 장치 카메라 나 이미지 선택기를 활성화합니다. fromCamera = YES이면 iPhone 및 iPad에서 모두 작동합니다. fromCamera = NO이면 iPhone에서 작동하고 이미지 선택 도구가 나타납니다. 하지만 다음 오류로 인해 iPad에서 충돌합니다. 이 기기에서는 UIStatusBarStyleBlackTranslucent를 사용할 수 없습니다. 나는 iPad가 UIStatusBarStyleBlackTranslucent statusBar를 표시 할 수 없다는 것을 이미 알고 있지만이 충돌을 어떻게 피할 수 있습니까?Crash iPad Photo Picker

-(void)addPhotoFromCamera:(BOOL)fromCamera{ 

if(fromCamera){  
    picker.sourceType = UIImagePickerControllerSourceTypeCamera; 
} 
else{ 
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
} 


[self presentModalViewController:picker animated:YES]; 

}

+0

분명히 누군가가 iPad와 함께 UIImagePickerControllerSourceTypePhotoLibrary를 사용 했습니까? – wasabi

답변

3

나는 UIImagePicker 당신의 Info.plist 파일 또는 현재 표시된 뷰 컨트롤러에서 반투명 상태 표시 줄을 상속 생각한다.

앱에 반투명 상태 표시 줄이없는 경우 어떻게됩니까? 나는 비슷한 문제가 발생했다

4

당신이 아이 패드에 UIImagePickerControllerSourceTypePhotoLibrary에 선택기를 설정하면, 당신은 popoverview에서이를 제시해야합니다 (!) 그렇지 않으면 예외가 발생합니다. 이어야가 팝 오버의 크기를 제어에 나는 (표준 크기는 내 의견으로는 너무 작), 이런 식으로 작업을 수행합니다

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { 
    if(imagePicker!=nil && rightPane.frame.size.width>0) 
     [imagePicker.view setFrame:imagePicker.view.superview.frame]; 
} 
:

-(void)openPhotoPicker 
{ 
    imagePicker = [[UIImagePickerController alloc] init]; 
    imagePicker.delegate = self; 
    imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
    imagePicker.navigationBar.opaque = true; 

    //put the image picker in its own container controller, to control its size 
    UIViewController *containerController = [[UIViewController alloc] init]; 
    containerController.contentSizeForViewInPopover = rightPane.frame.size; 
    [containerController.view addSubview:imagePicker.view]; 

    //then, put the container controller in the popover 
    popover = [[UIPopoverController alloc] initWithContentViewController:containerController]; 

    //Actually, I would like to do the following, but iOS doesn't let me: 
    //[rightPane addSubview:imagePicker.view]; 

    //So, put the popover over my rightPane. You might want to change the parameters to suit your needs. 
    [popover presentPopoverFromRect:CGRectMake(0.0, 0.0, 10.0,0.0) 
        inView:rightPane 
    permittedArrowDirections:UIPopoverArrowDirectionLeft 
        animated:YES]; 

    //There seems to be some nasty bug because of the added layer (the container controller), so you need to call this now and each time the view rotates (see below) 
    [imagePicker.view setFrame:containerController.view.frame]; 
} 

내가 또한 다음을, 회전 버그에 대응하기 위해

완벽하지는 않지만 지금은 테스트 목적으로는 괜찮습니다. 내가 Popoverview를 사용하도록 강요받는 것을 좋아하지 않기 때문에 나는 내 자신의 Imagepicker를 쓰는 것을 고려한다 ... 그러나 잘, 그것은 다른 이야기이다.