gpt4 book ai didi

iphone - 让 url 出现在 UITextview 中

转载 作者:行者123 更新时间:2023-11-29 13:37:26 25 4
gpt4 key购买 nike

此代码可以很好地使 url 出现在 UITextview 中

UITextView * descriptionTextView = [[UITextView alloc] initWithFrame:CGRectMake(10, 50, 300, 300)];
descriptionTextView.textColor = [UIColor whiteColor];
descriptionTextView.dataDetectorTypes = UIDataDetectorTypeLink;
descriptionTextView.font = [UIFont fontWithName:@"Helvetica" size:16];
descriptionTextView.backgroundColor = [UIColor clearColor];
descriptionTextView.text = @"Click to go to the google website, http://www.google.com ";
descriptionTextView.autocorrectionType = UITextAutocorrectionTypeNo;
descriptionTextView.keyboardType = UIKeyboardTypeDefault;
descriptionTextView.returnKeyType = UIReturnKeyDone;
descriptionTextView.editable = NO;
descriptionTextView.tag = 1;
[self.view addSubview:descriptionTextView];

问题是我写的整个网址都出现了,http://www.google.com

有没有办法只用一个词来包含链接?因此,用户只能看到蓝色的“Goggle”,当他们点击该作品时,它会打开 safari。

非常感谢,-代码

最佳答案

你可以使用 UIWebview

使用

- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL;

并对整个消息进行编码,然后将链接包装到

[webView.loadHTMLString:@"<a href="http://www.google.com/">Google</a>" baseURL:nil];

关于iphone - 让 url 出现在 UITextview 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10196478/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com