UITextView链接无法点击iOS 8

Mav*_*ave 5 uitextview ios

我遵循这个:UILabel和NSLinkAttributeName:链接不可点击, UITextView链接是可点击的,但当我点击它时,Safari不会打开 但无济于事.

我有 :

uitextView.attributedText = ... some attributed string "http://google.com" ...
Run Code Online (Sandbox Code Playgroud)

启用"链接检测","可选"和"启用用户交互"."可编辑"已禁用.

我也实施了 UITextViewDelegate

- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)url inRange:(NSRange)characterRange
{

    return YES;
}
Run Code Online (Sandbox Code Playgroud)

但是,链接显示为蓝色,但是当我点击时,没有任何反应.

Ale*_*ign 1

尝试采用这种方法:

NSString *clickMe = [NSString stringWithFormat:@"%@", word];
    NSMutableAttributedString * str2 = [[NSMutableAttributedString alloc] initWithString:word];
    [str2 addAttribute: NSLinkAttributeName value:[NSURL URLWithString:[NSString stringWithFormat:@"https://twitter.com/%@",linkWord]] range:NSMakeRange(0, clickMe.length)];

    // replace with link
    [YourAttributedString replaceCharactersInRange:wordRange withAttributedString:str2];
Run Code Online (Sandbox Code Playgroud)