UITableViewCell文本标签attributedText iOS7

UITableViewCell文本标签attributedText iOS7,ios,objective-c,uitableview,ios7,nsattributedstring,Ios,Objective C,Uitableview,Ios7,Nsattributedstring,我正在尝试将AttributeText设置为基本UITableViewCell中“textlabel”的值。 但是,单元格显示为空白!这是代码 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; // Configure the cell... NSDictionary *docattr = [NSDictionary new];

我正在尝试将AttributeText设置为基本UITableViewCell中“textlabel”的值。 但是,单元格显示为空白!这是代码

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

// Configure the cell...
NSDictionary *docattr = [NSDictionary new];
NSError *myerror = [NSError new];
NSString *htmlString = [[[dm latestUpdates] objectAtIndex:indexPath.row] objectForKey:@"display_data"];
NSMutableAttributedString *updateText = 
[[NSMutableAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUTF8StringEncoding] 
                                        options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, 
                                                  NSCharacterEncodingDocumentAttribute: [NSNumber numberWithInt:NSUTF8StringEncoding]} 
                             documentAttributes:&docattr 
                                          error:&myerror];

[cell.textLabel setAttributedText:updateText];
//   cell.detailTextLabel.attributedText = updateText;
NSLog(@"cell text %@", cell.textLabel.text);
//   cell.textLabel.text = htmlString;
return cell;
上面的代码将我的html转换为有效的属性字符串。但什么也没有显示。所讨论的html是

<div class='title'><a href='mc://guru_txn/171'>Wilbur Ross bought EXCO Resources, Inc.</a></div><div class='description'>Wilbur Ross bought 19,599,973 shares of EXCO Resources, Inc. (<a href='mc://quotes/XCO'>XCO</a>) @ $5.00 per share on 2014-01-17.</div>
Wilbur Ross于2014年1月17日以每股5.00美元的价格购买了EXCO Resources,Inc.19599973股股份。

我不知道如何指定我想要的各种“类”的值。但是,上面的html片段被解析为有效的属性字符串

我已经测试了您的代码,您的html字符串似乎有问题

我尝试将htmlString设置为@“
Test
”,结果成功了。然而,当我将“test”包装到标签中时,它就不再可见了

希望这能帮助你解决这个问题


注意:另外,尽量不要在
tableView:cellforrowatinexpath
:方法中分配对象。它真的可以减缓你的滚动

请尝试[[NSMutableAttributedString alloc]initWithString:htmlString]不起作用,html未被解析。请使用UILabel,而不要使用交互为否且scrollEnabled为否的UIWebView。我也看到了这一点。也许是iOS错误?我试着把它设置成一些基本的html“测试”。那也不行。另外,当我在
表格视图中分配单元格时:cellforrowatinexpath
。我使用的是动态原型,这是苹果公司推荐的代码。我也试过了。同样的结果。空的tableview单元格。我试图修改UITableViewCell原型,以说明textLabel是属性化的,但这无助于@“test”和@“test”或@“test

”,但一旦我添加了像@“这样的链接标记,它就不再起作用了。我注意到,从中删除href属性可以解决这个问题,但a失去了它的意义