0

이미지 선택 관리자를 모달로 추가 한 vc가 있고 사진을 선택하면 동일한 vc로 돌아갑니다. PickerController를 통해 이미지를 얻은 후에는 이미지를 화면에 추가하고, 사진이 가로 인 경우 장치가 가로로 자동 변경되도록하고 그림이 세로 인 경우 세로로 장치를 변경합니다.장치가 강제로 UIOrientation을 변경할 수 없습니다.

나는 실패 그냥 사진에 대한 별도의 VC를 인스턴스화하는 것이 가장 좋습니다 만약 내가 궁금하네요,

1. 

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft]; 

2. 
[UIViewController attemptRotationToDeviceOrientation]; 

-(NSUInteger)supportedInterfaceOrientations 
{ 

if (!isPortrait) //isPortrait is false when pic is landscape 
    return UIInterfaceOrientationMaskLandscape; 

} 

또는 풍경에 장치를 강제로 이러한 방법을 모두 시도했습니다. 나는이 question

답변

0

내 생각 엔 당신이 UIImagePickerController을 제시의 ViewController의 viewWillAppear: 방법 내부 [[UIApplication sharedApplication] setStatusBarOrientation: 전화를해야 후 지금까지 피할했습니다. 먼저 이미지 방향을 알 필요가 들어

, 당신은 같은 것을 할 수 있습니다

- (BOOL)shouldAutorotate { 
    return NO; 
} 

- (void) viewDidAppear:(BOOL)animated { 
    [super viewDidAppear:animated]; 

    if(myOrientation>0) 
     [UIApplication sharedApplication].statusBarOrientation = myOrientation; 
} 

- (void)presentPicker { 
    UIImagePickerController* imgPicker = [[UIImagePickerController alloc] init]; 
    imgPicker.delegate = self; 
    [self presentViewController:imgPicker animated:YES completion:nil]; 
} 

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    UIImage* image = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; 

    if(image.size.width>image.size.height) 
     myOrientation = UIInterfaceOrientationLandscapeLeft; 
    else 
     myOrientation = UIInterfaceOrientationPortrait; 

    [picker dismissViewControllerAnimated:YES completion:nil]; 
} 

을 또한, PLIST (처음에 초기 및 지원 인터페이스의 방향을 설정하는 것을 잊지 마세요 지원되는 방향은 초기 방향과 동일해야합니다)