Fix view problems on IPAD

This commit is contained in:
REIS Benjamin 2016-10-14 17:04:58 +02:00
parent c1f7b35560
commit ce4d238f79
2 changed files with 42 additions and 0 deletions

View file

@ -162,6 +162,25 @@
_editButton.hidden = ([ContactSelection getSelectionMode] != ContactSelectionModeEdit &&
[ContactSelection getSelectionMode] != ContactSelectionModeNone);
[_tableController.tableView addObserver:self forKeyPath:@"contentSize" options:0 context:NULL];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(deviceOrientationDidChange:)
name: UIDeviceOrientationDidChangeNotification
object: nil];
if (IPAD && self.contact == NULL) {
_editButton.hidden = TRUE;
_deleteButton.hidden = TRUE;
}
}
- (void)deviceOrientationDidChange:(NSNotification*)notif {
if (IPAD) {
if (self.contact == NULL || (self.contact.firstName == NULL && self.contact.lastName == NULL)) {
_editButton.hidden = TRUE;
_deleteButton.hidden = TRUE;
_avatarImage.hidden = TRUE;
}
}
}
- (void)viewWillDisappear:(BOOL)animated {
@ -198,6 +217,15 @@ static UICompositeViewDescription *compositeDescription = nil;
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
if (editing) {
_editButton.hidden = FALSE;
_deleteButton.hidden = FALSE;
_avatarImage.hidden = FALSE;
} else {
_editButton.hidden = TRUE;
_deleteButton.hidden = TRUE;
_avatarImage.hidden = TRUE;
}
if (animated) {
[UIView beginAnimations:nil context:nil];
@ -256,6 +284,8 @@ static UICompositeViewDescription *compositeDescription = nil;
_emptyLabel.hidden = NO;
if (!IPAD) {
[PhoneMainView.instance popCurrentView];
} else {
self.contact = NULL;
}
}
}

View file

@ -60,6 +60,7 @@ static UICompositeViewDescription *compositeDescription = nil;
if (IPAD) {
_backButton.hidden = YES;
_backButton.alpha = 0;
}
UITapGestureRecognizer *headerTapGesture =
@ -81,6 +82,11 @@ static UICompositeViewDescription *compositeDescription = nil;
selector:@selector(coreUpdateEvent:)
name:kLinphoneCoreUpdate
object:nil];
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(deviceOrientationDidChange:)
name: UIDeviceOrientationDidChangeNotification
object: nil];
}
- (void)viewWillDisappear:(BOOL)animated {
@ -94,6 +100,12 @@ static UICompositeViewDescription *compositeDescription = nil;
[self update];
}
- (void) deviceOrientationDidChange:(NSNotification*) notif {
if (IPAD) {
[self update];
}
}
#pragma mark -
- (void)update {