1
UICollectionView가 포함 된 UIViewController가 있습니다. UICollectionViewCell 중 하나를 두드리면 모달 뷰 컨트롤러가 나타납니다.iOS 7 : 모달 뷰 컨트롤러가 표시 될 때 장치의 현재 방향 제한
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
PopViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"DetailsView"];
vc.view.backgroundColor = [UIColor clearColor];
vc.transitioningDelegate = self;
vc.modalPresentationStyle = UIModalPresentationCustom;
[self presentViewController:vc animated:YES completion:nil];
PopViewController가 올바르게 표시됩니다. 이제 PopViewController가 제시 될 때 장치 방향을 제한하려고합니다. 즉, PopViewController가 세로 모드로 표시되면 PopViewController를 닫을 때까지 가로 모드 (가로 또는 세로로 회전 사용)로 전환하더라도 가로로 변경하면 안됩니다.
나는 PopViewController에 다음 코드를 사용했습니다 :
-(BOOL)shouldAutorotate {
return NO;
}
다른 사람 (또는 대신) 현재 방향에보기를 팝업을 고정하기 위해 필요한 것은 무엇?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return (toInterfaceOrientation == UIInterfaceOrientationPortrait);
}
이 시도했지만 여전히 같은 결과 : 모달 컨트롤러 –
C'mon !!! 이 예제를 실행하십시오. https://dl.dropboxusercontent.com/u/19438780/testRotate-portrait.zip – TonyMkenu
앱이 정상적으로 작동하고 있습니다. segue를 사용하여 모달 컨트롤러를 표시 할 때 내 응용 프로그램도 제대로 작동하지만 presentViewController 메서드를 사용할 때는 작동하지 않습니다. –