Don't use anymore shouldAutorotateToInterfaceOrientation: Private interface rotation

Fix adjustToFit in dialer view
This commit is contained in:
Yann Diorcet 2012-08-10 13:21:14 +02:00
parent 1efd76a60c
commit ec2a7a6856
7 changed files with 52 additions and 43 deletions

View file

@ -156,6 +156,8 @@ static UICompositeViewDescription *compositeDescription = nil;
[nineButton setDigit:'9'];
[starButton setDigit:'*'];
[sharpButton setDigit:'#'];
[addressField setAdjustsFontSizeToFitWidth:TRUE]; // Not put it in IB: issue with placeholder size
}
#pragma mark - Event Functions

View file

@ -82,7 +82,6 @@
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
<bool key="IBUIAdjustsFontSizeToFit">YES</bool>
<float key="IBUIMinimumFontSize">15</float>
<object class="IBUITextInputTraits" key="IBUITextInputTraits">
<int key="IBUIAutocorrectionType">1</int>
@ -606,6 +605,7 @@
<string key="NSFrame">{{214, 0}, {106, 69}}</string>
<reference key="NSSuperview" ref="32193173"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>

View file

@ -77,7 +77,6 @@
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
<bool key="IBUIAdjustsFontSizeToFit">YES</bool>
<float key="IBUIMinimumFontSize">15</float>
<object class="IBUITextInputTraits" key="IBUITextInputTraits">
<int key="IBUIAutocorrectionType">1</int>
@ -603,7 +602,6 @@
<string key="NSFrame">{{126, 0}, {186, 85}}</string>
<reference key="NSSuperview" ref="683359487"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBIPadFramework</string>

View file

@ -21,7 +21,7 @@
@implementation UIAddressTextField
- (void) setText:(NSString *)text {
- (void)setText:(NSString *)text {
[super setText:text];
[self sendActionsForControlEvents:UIControlEventEditingChanged];
}

View file

@ -180,6 +180,11 @@
[self.contentViewController viewWillAppear:animated];
[self.tabBarViewController viewWillAppear:animated];
[self.stateBarViewController viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(orientationDidChange:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
}
@ -197,6 +202,10 @@
[self.stateBarViewController viewWillDisappear:animated];
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIDeviceOrientationDidChangeNotification
object:nil];
}
- (void)viewDidDisappear:(BOOL)animated {
@ -207,18 +216,18 @@
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
currentOrientation = [self getCorrectInterfaceOrientation:toInterfaceOrientation];
[super willRotateToInterfaceOrientation:currentOrientation duration:duration];
[self.contentViewController willRotateToInterfaceOrientation:currentOrientation duration:duration];
[self.tabBarViewController willRotateToInterfaceOrientation:currentOrientation duration:duration];
[self.stateBarViewController willRotateToInterfaceOrientation:currentOrientation duration:duration];
currentOrientation = toInterfaceOrientation;
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
[self.contentViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
[self.tabBarViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
[self.stateBarViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willAnimateRotationToInterfaceOrientation:currentOrientation duration:duration];
[self.contentViewController willAnimateRotationToInterfaceOrientation:currentOrientation duration:duration];
[self.tabBarViewController willAnimateRotationToInterfaceOrientation:currentOrientation duration:duration];
[self.stateBarViewController willAnimateRotationToInterfaceOrientation:currentOrientation duration:duration];
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
[self.contentViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
[self.tabBarViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
[self.stateBarViewController willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
[self update:nil tabBar:nil stateBar:nil fullscreen:nil];
}
@ -230,23 +239,24 @@
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if(currentViewDescription != nil) {
NSString* rotationPreference = [[LinphoneManager instance].settingsStore objectForKey:@"rotation_preference"];
if (UIInterfaceOrientationIsPortrait(interfaceOrientation) && [currentViewDescription portraitMode] &&
([rotationPreference isEqualToString:@"auto"] || [rotationPreference isEqualToString:@"portrait"])) {
return YES;
}
if (UIInterfaceOrientationIsLandscape(interfaceOrientation) && [currentViewDescription landscapeMode] &&
([rotationPreference isEqualToString:@"auto"] || [rotationPreference isEqualToString:@"landscape"])) {
return YES;
}
return NO;
}
return YES;
if(interfaceOrientation == currentOrientation)
return YES;
return NO;
}
#pragma mark -
#pragma mark - Event Functions
- (void)orientationDidChange:(NSNotification*)notif {
// Update rotation
UIInterfaceOrientation correctOrientation = [self getCorrectInterfaceOrientation:[[UIDevice currentDevice] orientation]];
if(currentOrientation != correctOrientation) {
[PhoneMainView forceOrientation:correctOrientation animated:currentOrientation!=UIDeviceOrientationUnknown];
}
}
#pragma mark -
- (void)clearCache {
[viewControllerCache removeAllObjects];
@ -295,10 +305,19 @@
- (UIInterfaceOrientation)getCorrectInterfaceOrientation:(UIDeviceOrientation)deviceOrientation {
if(currentViewDescription != nil) {
// If unknown return status bar orientation
if(deviceOrientation == UIDeviceOrientationUnknown && currentOrientation == UIDeviceOrientationUnknown) {
return [UIApplication sharedApplication].statusBarOrientation;
}
NSString* rotationPreference = [[LinphoneManager instance].settingsStore objectForKey:@"rotation_preference"];
if([rotationPreference isEqualToString:@"auto"]) {
if(deviceOrientation == UIDeviceOrientationUnknown) {
return [UIApplication sharedApplication].statusBarOrientation;
// Don't rotate in UIDeviceOrientationFaceUp UIDeviceOrientationFaceDown
if(!UIDeviceOrientationIsPortrait(deviceOrientation) && !UIDeviceOrientationIsLandscape(deviceOrientation)) {
if(currentOrientation == UIDeviceOrientationUnknown) {
return [UIApplication sharedApplication].statusBarOrientation;
}
return currentOrientation;
}
if (UIDeviceOrientationIsPortrait(deviceOrientation)) {
if ([currentViewDescription portraitMode]) {
@ -317,9 +336,6 @@
} else if([rotationPreference isEqualToString:@"portrait"]) {
if ([currentViewDescription portraitMode]) {
if (UIDeviceOrientationIsPortrait(deviceOrientation)) {
if(deviceOrientation == UIDeviceOrientationUnknown) {
return [UIApplication sharedApplication].statusBarOrientation;
}
return deviceOrientation;
} else {
if(UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation)) {
@ -334,9 +350,6 @@
} else if([rotationPreference isEqualToString:@"landscape"]) {
if ([currentViewDescription landscapeMode]) {
if (UIDeviceOrientationIsLandscape(deviceOrientation)) {
if(deviceOrientation == UIDeviceOrientationUnknown) {
return [UIApplication sharedApplication].statusBarOrientation;
}
return deviceOrientation;
} else {
if(UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {
@ -427,7 +440,6 @@
UIInterfaceOrientation correctOrientation = [self getCorrectInterfaceOrientation:[[UIDevice currentDevice] orientation]];
if(currentOrientation != correctOrientation) {
[PhoneMainView forceOrientation:correctOrientation animated:currentOrientation!=UIDeviceOrientationUnknown];
currentOrientation = correctOrientation;
} else {
[self updateInterfaceOrientation:correctOrientation];
}

View file

@ -75,7 +75,7 @@
}
if (addressField && (!dtmf || !linphone_core_in_call([LinphoneManager getLc]))) {
NSString* newAddress = [NSString stringWithFormat:@"%@%c",addressField.text, digit];
[addressField setText:newAddress];
[addressField setText:newAddress];
linphone_core_play_dtmf([LinphoneManager getLc], digit, -1);
} else {
linphone_core_send_dtmf([LinphoneManager getLc], digit);
@ -101,7 +101,6 @@
if (digit == '0') {
NSString* newAddress = [[addressField.text substringToIndex: [addressField.text length]-1] stringByAppendingString:@"+"];
[addressField setText:newAddress];
[addressField sendActionsForControlEvents:UIControlEventEditingChanged];
}
}

View file

@ -164,11 +164,9 @@ static PhoneMainView* phoneMainViewInstance=nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if(mainViewController != nil) {
return [mainViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
} else {
if(interfaceOrientation == self.interfaceOrientation)
return YES;
}
return NO;
}
/*
@ -219,7 +217,7 @@ static PhoneMainView* phoneMainViewInstance=nil;
}
[controller didRotateFromInterfaceOrientation:oldOrientation];
}
[[UIApplication sharedApplication] setStatusBarOrientation:orientation animated:TRUE];
[[UIApplication sharedApplication] setStatusBarOrientation:orientation animated:animated];
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {