使用标签在tableView单元格中正确显示的问题 [英] Problem in displaying properly in tableView cell by using label

查看:36
本文介绍了使用标签在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单元格中正确显示的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆