We have an iPhone app that is doing a lot of rotation between portrait and landscape. Everything is mostly working properly, but it doesn't seem to pick up orientation changes quickly enough (and some times not at all). Is there a way of telling the default rotation handling that we need updates faster? 开发者_高级运维I'd rather not write custom accelerometer code, but with the accelerometer I know I can specify how quickly I need to receive updates.
Not sure how you are getting notified about your orientation change but im using - (void)orientationChanged:(NSNotification *)notification. This updates at least in the simulator faster than twice a second which imo is fast enough for me.
Ah yeah, I had issues with that. In an example app of apples or their doco (i cant remember) it uses:
- (void)orientationChanged:(NSNotification *)notification { [self performSelector:@selector(updateLandscapeView) withObject:nil afterDelay:0]; }
Than you build a method that does
- (void)updateLandscapeView { if (UIDeviceOrientationIsLandscape(deviceOrientation) && !isShowingLandscapeView) { [self presentModalViewController:scheduleMonth animated:YES]; isShowingLandscapeView = YES; } else if (deviceOrientation == UIDeviceOrientationPortrait && isShowingLandscapeView) { [self dismissModalViewControllerAnimated:YES]; isShowingLandscapeView = NO; } }
I put my landscape orientation in a separate class that gets called in updateLandscapeView
If you have a complex landscape view you may load it from a thread perhaps and if it goes back to portrait halt the thread and dismiss the view. The user might not get the landscape view if they do it quickly but means they wont get glitches or be stuck on landscape or portrait view.
精彩评论