Problem in displaying properly in tableView cell by using label

你离开我真会死。 提交于 2020-01-07 07:27:08

问题


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.

This is my code:-

- (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;
}

and in this way i configured my TableCell3.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.

Thanks in Advance.

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...


回答1:


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

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.

and maybe i am wrong ?

Good luck Shani




回答2:


Adjust frame of an UiLabel to have more space for two lines or decrease font size.



来源:https://stackoverflow.com/questions/6192025/problem-in-displaying-properly-in-tableview-cell-by-using-label

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!