tags:

views:

35

answers:

4

Hello everyone

I have some source codes to display all file names in a UITablView

I noticed that if the file name too long, for example filenameabcdefghklmn.dat it will display filenameabcde...

I hope to know what is the best way to display long file name in UITablView?

Thanks

interdev

A: 

Allow rotation to landscape mode. Or use a smaller font. Or just let the label get abbreviated with the "..." ellipsis.

There isn't a heck of a lot you can do here.

Shaggy Frog
A: 

Show long name in two line in same row...

like

if([myString length] > MAX)
{
      myString1 = [myString substringToIndex:MAX];

      cell.textLabel.text = myString1;
      mystring2 = [myString substringFromIndex:MAX];
      cell.detailTextLabel.text = mystring2;

}
mihirpmehta
A: 

Customise your table cell and draw the string directly to the table cell's view.

You can use sizeWithFont:constrainedToSize: to figure out how big your string will be so you can size your cell appropriately.

This post may help you out:

http://www.ubergeek.tv/article.php?pid=143

Jasarien
+2  A: 

You can set the label properties of the label in which you are entering text like:

[lbl setNumberOfLines:0];
[lbl setLineBreakMode:UILineBreakModeCharacterWrap];

Now this will show the file name in the next line if the file name did not fit in one line.

You need to adjust the label height also.

Hope this helps,

Thanks,

Madhup

Madhup
Note that if you support editing of the table, you should set the number of lines to the actual number of lines instead of 0. If you use 0, the string might overlap when going into edit mode.
Rengers