Reformat phone number if user changes country code.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-04-06 21:35:11 -04:00
parent df381cf4b9
commit 5feca42821
2 changed files with 3 additions and 7 deletions

View File

@ -436,6 +436,8 @@ NSString *const kContactsTable_CellReuseIdentifier = @"kContactsTable_CellReuseI
[self updateCountryWithName:countryName
callingCode:callingCode
countryCode:countryCode];
[self textField:_phoneNumberTextField shouldChangeCharactersInRange:NSMakeRange(0, 0) replacementString:@""];
}
#pragma mark - UITextFieldDelegate

View File

@ -223,13 +223,7 @@ static NSString *const kCodeSentSegue = @"codeSent";
countryCode:vc.countryCodeSelected];
// Reformat phone number
NSString *digits = _phoneNumberTextField.text.digitsOnly;
NSString *reformattedNumber =
[PhoneNumber bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:digits
withSpecifiedCountryCodeString:_countryCodeButton.titleLabel.text];
_phoneNumberTextField.text = reformattedNumber;
UITextPosition *pos = _phoneNumberTextField.endOfDocument;
[_phoneNumberTextField setSelectedTextRange:[_phoneNumberTextField textRangeFromPosition:pos toPosition:pos]];
[self textField:_phoneNumberTextField shouldChangeCharactersInRange:NSMakeRange(0, 0) replacementString:@""];
}
#pragma mark iPhone 5s or shorter