使用标签在tableView单元格中正确显示的问题

编程入门 行业动态 更新时间:2024-10-28 15:34:23
本文介绍了使用标签在tableView单元格中正确显示的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的应用程序中,我通过NSXMLParser解析了数据,并创建了单独的类来存储通常用于显示数据的数据.除了标题显示在带有图像的表格单元中外,其他所有内容在模拟器中都可以正常运行.图像显示正确,但标题显示不正确.

In my application I parsed the data through NSXMLParser and made separate class to store that data from which i usually display the data. Everything works fine in simulator except the the title which is display in table cell with image. Images appears properly but the title not appear properly.

这是我的代码:-

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { [[NSBundle mainBundle] loadNibNamed:@"TableCell3" owner:self options:NULL]; cell = nibLoadedCell; } NewsInfo *aNewsInfo = [appDelegate.newsArray objectAtIndex:indexPath.row]; titleLabel.text = aNewsInfo.title; imageLabel.image = aNewsInfo.smallImageData; return cell; }

并以此方式配置了TableCell3.xib

and in this way i configured my TableCell3.xib

现在,我希望我的标题数据在TableCell3的标签中分2行显示.我已经通过xib属性设置或代码使用了这两种方法.我用来代替该xib属性设置的代码是:-

Now i want my title data in 2 rows in label of the TableCell3. I already used both the way through xib attributes settings or through code. Code which i used instead of this xib attributes settings are:-

titleLabel.lineBreakMode = UILineBreakModeWordWrap; titleLabel.numberOfLines = 2; titleLabel.text = aNewsInfo.title;

现在,有谁能帮助我找出这个问题,我想在表格视图单元格的两行中显示我的标题.

Now Can any one help me to figure out this prob i want to display my title in two rows of the table view cell.

预先感谢.

我的数据正以这种方式显示...![在此处输入图片描述] [2]

My Data is showing in this way...![enter image description here][2]

所以我想完全显示此标题,它现在部分显示...我想分两行显示...

So i want to display this title fully it show's partially right now... i want to display in two lines...

推荐答案

我的猜测是您需要扩大标签高度.

My guess is that you need to enlarge the label height.

也许标签的高度我不足以显示2行文本,这可能是您仅看到1行的原因.

Maybe the label height i not large enough to display 2 lines of text and that's could be the reason that you see only 1 line.

在界面构建器中尝试扩大标签高度.

in interface builder try to enlarge the label height.

也许我错了吗?

祝你好运沙尼

更多推荐

使用标签在tableView单元格中正确显示的问题

本文发布于:2023-11-26 20:25:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635072.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元格   正确   标签   tableView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!