UIViewController가 iOS7 용으로 빌드 된 응용 프로그램을 가로 세로 왼쪽과 세로 세로 세로로 지원해야하며 다른 ViewController는 가로 방향의 가로 방향 만 지원해야합니다. 알림을 사용하여 방향 변경을 알리고 그에 따라 하위 뷰를 새로 고칩니다. 또한 UIDevice의 현재 회전 방향을 확인하려고합니다. 내가 직면하고있는 문제는보기를 새로 고침하는 약간의 흔들림 또는 기울기 트리거 방향 변경 방법입니다. 나는 그때 거기 기괴한 전망 구조를 얻는다조차. 나는 각각 beginGeneratingDeviceOrientationNotifications 및 endGeneratingDeviceOrientationNotifications을 viewDidLoad 및 viewWillDisappear에 각각 사용합니다. 기기 회전만으로 제한 할 수있는 방법이 있습니까?장치 위아래로 기울이기 및 옆으로 트리거 방향 알림 트리거
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceDidRotate:) name:UIDeviceOrientationDidChangeNotification object:nil]; // adding observer to notify when device rotates.
deviceDidRotate : 실제로 피하고 싶은 작은 기울기 나 흔들림에도 호출됩니다.
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
//Ignoring specific orientations
if (orientation == UIDeviceOrientationFaceUp||orientation == UIDeviceOrientationFaceDown ||orientation == UIDeviceOrientationUnknown)
{
return;
}
if ((UIDeviceOrientationIsPortrait(orientation) || UIDeviceOrientationIsLandscape(orientation))) {
[UIViewController attemptRotationToDeviceOrientation];
}
내가 약간의 흔들림이나 기울기에 통지 트리거를 건너 뛸 수있는 방법이 대리자 메서드
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[self handleViewArrangementWithCurrentOrientation];
}
을 사용하고있는 틸트 효과를 방지하려면. 실제로 애니메이션의 방향 변경에 대한 화면을 새로 고침하여 깜박 거리는 효과와 그 빈번한 느낌을줍니다. 나는 이것을 제거해야한다. 제발 도와주세요.
틸트 업/다운은 Z 축이 아닌 X 축을 중심으로 회전합니다. – trojanfoe
예, UIDevice 방향이 급격하게 변동합니다. 보기 컨트롤러 회전을 설정하는 데 사용해서는 안됩니다. 보기 컨트롤러에서 viewDidRotate를 사용할 수없는 이유가 있습니까? 또는 더 나은 방법은 autolayout을 사용하는 것입니다. –
@AnnaDickinson : 자동 레이아웃을 사용하고 있습니다. 레이아웃 문제가 아닙니다. 알림을 트리거하기 때문에 작은 흔들림/기울임에 대해서도 뷰 새로 고침을 호출하는 코드가 생깁니다. 이것을 피하려면 어떻게해야합니까? 사용자는 이것을 버그라고 생각합니다. 다른 방법이 있습니까? – Meera