I've created an app which will call a 5 digit hospital extension number that the user enters in to a textField by prefixing it with the switchboard number.
As all extensions are 5 digits I would rather the app initiate a telprompt when it counts 5 digits rather than have the user press a call button. I have this so far but for some reason it is missing off the 5th digit when it shows the telprompt. (i.e. if the user enters "12345" the telprompt only shows "1234". Any ideas why?
- (BOOL)textField:(UITextField *)numberTextField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
NSUInteger newLength = [self.numberTextField.text length] + [string length] - range.length;
if (newLength == 5) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt:(01233633331)(P)(%@)", self.numberTextField.text]]];
}
return YES;
}