Reformat phone number if user changes country code.

// FREEBIE
pull/1/head
Matthew Chen 7 years ago
parent df381cf4b9
commit 5feca42821

@ -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

@ -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

Loading…
Cancel
Save