标签: tttattributedlabel

在UILabel中显示HTML文本,性能问题.[iPhone SDK,iOS 8,Swift]

我试图在UILabel中显示格式正确的HTML文本并成功使用以下代码:

    // Create the html body
    var attributedHTMLBody = NSAttributedString(data: comment.bodyHTML.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: false), options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil, error: nil)

    // Create the string including the text style
    var htmlString = String(format: "<div style='font-size: 16px; font-family: HelveticaNeue-Light;'>%@", attributedHTMLBody.string)

    // Create the final text to display
    var attributedHML = NSAttributedString(data: htmlString.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: false), options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil, error: nil)

    // Set the text
    cell.commentLabel.attributedText = attributedHML

    // Find the locations of any links
    var mutableLinkArray = NSMutableArray()
    var mutableRangeArray = …
Run Code Online (Sandbox Code Playgroud)

ios tttattributedlabel swift

4
推荐指数
1
解决办法
7046
查看次数

iPhone - 从UILabel的链接中删除下划线

我正在使用TTTAttributedLabel(https://github.com/twotoasters/TTTAttributedLabel).在这里,我正确地获得了带有一些可点击文本的标签.

在此输入图像描述

我需要像上面图片中的用户名一样显示我的文字(即没有下划线).我怎么能这样做?

iphone hyperlink uilabel ios tttattributedlabel

3
推荐指数
1
解决办法
3221
查看次数

TTTAttributedLabel 链接检测无法使用 Storyboard

我正在尝试将 TTTAttributedLabel 集成到 UITableViewCell 中。这真的只是一个简单的集成,我想要的只是用 TTTAttributedLabel 替换旧的 UILabel。这就是我所做的。

  1. 转到 Storyboard 并选择自定义 UITableViewCell 中的 UILabel 并将其类更改为 TTTAttributedLabel
  2. 回到 UITableViewController 子类,包含 TTTAttributedLabel.h,修改(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 如下:

    static NSString *CellIdentifier = @"Post";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(cell == nil)
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                      reuseIdentifier:CellIdentifier];
    
    TTTAttributedLabel *label = (TTTAttributedLabel *)[cell viewWithTag:801];
    label.text = [self.post valueForKey:@"content"];
    label.enabledTextCheckingTypes = NSTextCheckingTypeLink;
    label.userInteractionEnabled = YES;
    label.delegate = self;
    return cell;
    
    Run Code Online (Sandbox Code Playgroud)

但是链接检测不起作用。这只是纯文本。如何调试我做错了什么?

objective-c ios tttattritubedlabel tttattributedlabel

3
推荐指数
1
解决办法
4001
查看次数

Xcode UIAutomation无法与TTTAttributedLabel交互

我正在尝试为我的应用程序编写自动化脚本,我的问题是Xcode UI Automation无法看到TTTAttributedLabel类的元素.获取完整元素树不会显示这些TTTAttributedLabel元素的迹象.我正在使用Xcode 6.1.1

xcode automation ios appium tttattributedlabel

2
推荐指数
1
解决办法
546
查看次数

TTTAttributedLabel sizetofit和sizeWithFont是不同的

我正在使用TTTAttributedLabel,我通常在tableview单元格中使用sizetofit.之后,我在单元格高度计算中使用sizeWithFont.我像这样设置了TTTAttributedLabel.

[self.attributedLabel setText:@"Test\n\n\n\n"];
CGSize contentSize = [self.attributedLabel.text sizeWithFont:self.attributedLabel.font
                                      constrainedToSize:CGSizeMake(CGRectGetWidth(self.attributedLabel.frame), 1000)
                                          lineBreakMode:NSLineBreakByWordWrapping];

[self.attributedLabel sizeToFit];
Run Code Online (Sandbox Code Playgroud)

我注意到身高不同了.我得到了这样的输出.所以我猜这是错的.我可以知道如何解决?我在iOS 8设备上测试.

在此输入图像描述

uilabel sizewithfont ios sizetofit tttattributedlabel

1
推荐指数
1
解决办法
1435
查看次数