0

사용자가 앱을 실행할 때 이미지를 보여주고 싶습니다. 이 이미지는 20 초 동안 표시됩니다.앱을 시작할 때 방향을 잠그고 ViewController로 이동할 때 잠금을 해제하려면 어떻게해야합니까?

사용자가 가로 모드에서 앱을 시작하면 앱이 가로 모드로 유지되는 기능을 원합니다. 그리고 사용자가 Portrait에서 App을 lauches하면 App은 Portrait로 유지됩니다.

저는이 이미지를 표시하기 위해 별도의 viewcontroller를 만들었으므로 Appelegate에서 이것을 구성하는 것이 힘들었습니다. 타이머가 끝나면 회전을 활성화해야하는 다음보기로 이동합니다.

어떻게하면 iPad의 UI를 임시로 잠글 수 있습니까?

편집 :

나는 내 AppDelegate에 후 처음의 ViewController에있는 viewDidLoad 내에서 방향 검사를 구현하여이 문제를 해결했습니다. 모든 방향에 대해 나는 값을 저장했다. shouldAutorotate를 수행 할 때 : 먼저 방향 변경을 불가능하게하는 저장된 값을 확인합니다. 코드에서

솔루션 :

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; 
    if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) { 
     [[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"PortraitLandscapeIndicator"]; 
    } 
    else { 
     [[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"PortraitLandscapeIndicator"]; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    //the latest saved orientation is our orientation 
    if([[NSUserDefaults standardUserDefaults] integerForKey:@"PortraitLandscapeIndicator"] == 1){ 
     return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight)); 
    } 
    else{ 
     return ((interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)); 

    } 

} 

답변

0

는 소리 지원되는 모든 방향으로 회전을 허용 할 수 있습니다

초기 저장된 값과 동일 loadView 또는 init에서 장치 방향을 얻는 시작에 표시된 다음 뷰 프레임을 적절하게 설정하고 세로 또는 가로 모드에 기반하여 [shouldAutorotateToInterfaceOrientation :]에서 허용 된 방향 만 반환합니다.

타이머가 끝나면 다른 viewController로 컨트롤을 전달하여 거기에서 가져 오거나 다른 방향을 허용 할 수 있습니다.

그러나 결론은 프로그래밍 방식으로 어떤 구성표를 사용하든 가장 잘 작동 할 것이라고 생각합니다.

0

당신이 먼저 shouldAutorotateToInterfaceOrientation: 방법 다음, 이미지를 표시 할 때, 초기 interfaceOrientation (뷰 컨트롤러의 속성을) 저장 YES 방향이있는 경우에만 반환해야 타이머가 완료되면 당신은 특별한의 ViewController 가져 곳에 뭔가를해야 할 것 같은, 당신이

관련 문제