내 독자 앱에 맞춤 오리엔테이션 잠금 버튼을 만들고 싶습니다. 나는 채찍질하기에는 너무 나쁘지 않을 것이라고 생각했습니다.하지만 슬프게도 나는 휘핑을 입었습니다. 이를사용자 지정 방향 잠금 동작을 수행하려면 어떻게해야합니까?
- (IBAction) screenLock:(id)sender{
if([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait){
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
}else{
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
}
}
그러나 슬프게도 : 다음
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
그리고 나는이 같은 작업 방법의 실제 잠금을 처리 할 수 있다고 생각했다 :
나는이 방법이 어떻게 시작하려면 코드가 회전하여보기를 지시하는 전자에 흔들리지 않습니다 ...
이 모든 것이 잘못 될까요? 그것을하는 더 좋은 방법은 무엇입니까? 사용자가 화면의 방향을 잠글 수있게하기위한 로컬 쉬운 방법을 원합니다. 나는 잠금 버튼을 눌렀을 때 부울 값을 사용하여 잠금을 해제하고 다시 누를 것이라고 추측합니다 ...
생각 하시겠습니까? 감사합니다.
번호가이 방법은 지원 방향에 대해 YES를 반환해야합니다 귀하의 경우 항상 YES 또는 항상 NO 중 하나를 반환합니다. – Eiko
@Eiko, 현재 쓰여지고있는 방식으로 잠금이 활성화되어 있으면보기 컨트롤러가 모든 방향으로 회전하고 (잠금이 활성화되지 않은 경우 YES를 반환 함) 잠금이 전혀 회전하지 않도록 할 수 있습니다. 왜 이것이 downvote받을 가치가 있는지 모르겠다? – Jasarien
에코 (Eiko)는 맞았습니다. 수정본을 편집했지만. –