我将html文本设置为UITextView并将UIDataDetectorTypeLink设置为DataDetectorTypes,但它不工作。下面是代码:`
self.dictHelp =[NSMutableDictionary dictionaryWithDictionary:response];
[self.txtView setValue:[self.dictHelp valueForKey:@"HelpText"] forKey:@"contentToHTMLString"];
self.txtView.userInteractionEnabled = YES;
[self.txtView setDataDetectorTypes:UIDataDetectorTypeLink];`
文字值为"如果您需要帮助,请通过customerservice@xxxx.org"与XXXX联系; 我做错了什么?
答案 0 :(得分:1)
请检查此代码,我在此Link中找到了: - 这是一个解决方法,但效果很好!
self.txtView.selectable = NO; // set it to NO clears all possible data detection work so far.
self.txtView.selectable = YES; // set it to YES so that actual links are detected.
答案 1 :(得分:0)
请尝试以下方式 -
self.txtView.text = nil;
[self.txtView setValue:nil forKey:@"contentToHTMLString"];
[self.txtView setValue:[self.dictHelp valueForKey:@"HelpText"] forKey:@"contentToHTMLString"];