#pragma mark - <識手機(jī)號>
- (void)validPhoneNumFromString:(NSString*)string {
? ? NSError*error;
? ? //根據(jù)檢測的類型初始化
? ? NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypePhoneNumber error:&error];
? ? //獲得檢測所得到的數(shù)組
? ? NSRange stringRange =NSMakeRange(0, string.length);
? ? NSArray *matches = [detector matchesInString:string options:0 range:stringRange];
? ? for(NSTextCheckingResult *match in matches) {
? ? ? ? if (match.resultType == NSTextCheckingTypePhoneNumber) {
? ? ? ? ? ? NSRange phoneRange = [match range];
? ? ? ? ? ? _phoneStr = [string substringWithRange:phoneRange];
? ? ? ? ? ? if(_phoneStr.length>0) {
? ? ? ? ? ? ? ? _bubbleView.textLabel.userInteractionEnabled = YES;
? ? ? ? ? ? ? ? UITapGestureRecognizer*tap = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(phoneLink)];
? ? ? ? ? ? ? ? [_bubbleView.textLabeladdGestureRecognizer:tap];
? ? ? ? ? ? }
? ? ? ? }
? ? }
}
#pragma mark - 點(diǎn)擊撥打電話
- (void)phoneLink {
????NSMutableString *phone = [[NSMutableString alloc] initWithFormat:@"tel:%@",_phoneStr];
?????[[UIApplication sharedApplication] openURL:????[NSURL URLWithString:phone]];
}