Jest to obserwacja bardziej niż cokolwiek innego, bo wydaje się, że znaleźli obejście ...[UIDevice currentDevice] .orientation == UIDeviceOrientationUnknown następujące UINavigationController naciskać
Poniższy kod nie działa kiedy to w kontroler, który został wciśnięty na stos UINavigationController. W tej sytuacji [UIDevice currentDevice].orientation
konsekwentnie zwraca UIDeviceOrientationUnknown
.
-(void)layoutAccordingToOrientation {
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
NSLog(@"layoutAccordingToOrientation/orientation==%i", orientation);
if (UIInterfaceOrientationIsLandscape(orientation)) {
:
_detailToolbar.frame = CGRectMake(0, 660, 1024, 44);
} else {
:
_detailToolbar.frame = CGRectMake(0, 916, 768, 44);
}
}
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[self layoutAccordingToOrientation];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
następujące wywołanie został poczyniono:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
Aby obejść ten UIDeviceOrientationUnknown
-problem, teraz kliknąć na poniższy zamiast:
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsLandscape(orientation)) {
etc.
} else {
etc.
}
... który działa każdego razu.
Nadal nie rozumiem, dlaczego pierwsza odmiana nie działałaby w kontekście kontrolera widoku pchanego. Czy ktoś ma pomysły? Czy to po prostu błąd?
Mam ten sam problem, ale nie jestem w stanie sprawić, by twoja praca również działała w mojej sytuacji. – Flea