사용자가 앱을 실행할 때 이미지를 보여주고 싶습니다. 이 이미지는 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));
}
}