UICompositeView.m: try to fix some crash in rotation handling

This commit is contained in:
Gautier Pelloux-Prayer 2016-04-05 14:06:37 +02:00
parent 6bae5dab90
commit 9cc1a2c9f2
2 changed files with 17 additions and 12 deletions

View file

@ -153,6 +153,7 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[self.mainViewController viewWillAppear:animated];
[self.detailsViewController viewWillAppear:animated];
[self.tabBarViewController viewWillAppear:animated];
@ -162,7 +163,6 @@
selector:@selector(orientationDidChange:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
}
- (void)viewDidAppear:(BOOL)animated {
@ -175,25 +175,23 @@
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[self.mainViewController viewWillDisappear:animated];
[self.detailsViewController viewWillDisappear:animated];
[self.tabBarViewController viewWillDisappear:animated];
[self.statusBarViewController viewWillDisappear:animated];
[self.sideMenuViewController viewWillDisappear:animated];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
[NSNotificationCenter.defaultCenter removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[self.mainViewController viewDidDisappear:animated];
[self.detailsViewController viewDidDisappear:animated];
[self.tabBarViewController viewDidDisappear:animated];
[self.statusBarViewController viewDidDisappear:animated];
[self.sideMenuViewController viewDidDisappear:animated];
[super viewDidDisappear:animated];
}
#pragma mark - Rotation messages
@ -239,11 +237,18 @@
#pragma mark - Event Functions
- (void)orientationDidChange:(NSNotification *)notif {
// Update rotation
UIInterfaceOrientation correctOrientation =
[self getCorrectInterfaceOrientation:[[UIDevice currentDevice] orientation]];
if (currentOrientation != correctOrientation) {
[UICompositeView setOrientation:correctOrientation animated:currentOrientation != UIDeviceOrientationUnknown];
@try {
// Update rotation
UIInterfaceOrientation correctOrientation =
[self getCorrectInterfaceOrientation:[[UIDevice currentDevice] orientation]];
if (currentOrientation != correctOrientation) {
[UICompositeView setOrientation:correctOrientation
animated:currentOrientation != UIDeviceOrientationUnknown];
}
} @catch (NSException *exception) {
// There are some crashes reports from iTunes connect because Linphone core is
// not ready yet - whatever the reason is, we can safely ignore the exception
LOGE(@"Exception: %@, ignoring", exception);
}
}

View file

@ -25,7 +25,7 @@ INIT_WITH_COMMON_CF {
[self setRoundRadius];
[NSNotificationCenter.defaultCenter addObserver:self
selector:@selector(orientationDidChange:)
name:@"UIDeviceOrientationDidChangeNotification"
name:UIDeviceOrientationDidChangeNotification
object:nil];
return self;
}