views:

307

answers:

5

I have a very long string that i need to display in the first row of the table view. The string is like

"1|123|Try|Bank Of America|11/06/2007|20,000.00"

where | is the tokenizer.

Now I take the first token ie 1 and append String "\n", so that 123 is displayed in the next line of the row of table view, but I can just display 1 and 123 in the first row of the table view. I can't display the other values.

See the case is, the result string is the information of a transaction, similarly there are many more transactions that i will be displaying in the table view. But the rows in table are not big enough to display the entire information.

+1  A: 

If I read your question correctly you want to increase the height of the row?

If so, you can use the delegate:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
rein
please can you explain in more detail, how and where do i need to make changes in my code
shreedevi
Your UITableView has to set its delegate (and datasource) to be your class (typically your ViewController for that view). In your ViewController class you can add that delegate method and return a custom height for the row. Delegates are kinda integral to the whole objective-c programming model and if you're lost with them I would suggest reading up on them a bit before advancing.
rein
i tried this, it increase the height of the row, but displays only 2 lines in the row, and the remaining data is shown as .........
shreedevi
A: 

Sounds like you are using the standard UITableViewCell. I'd recommend using a custom tableViewCell with a UILabel so you can control how the truncation is handled and how many lines you can have, etc. You still have to use @rein's suggestion of resizing the rows.

mahboudz
A: 

You're going to have alter the height of the tableview cell depending on how many lines of data you want to display in each row. You will need to write a UITableViewDelegate's tableView:heightForRowAtIndexPath: to return the correct row height for each row.

Calculating the row height will prove tricky if the number of lines of text changes each time or if the font size changes.

You might want to rethink your design. Tableviews are not intended to display a large amount of information. Instead, they are intended to display information that more or less fits on one line. You should consider a design that displays one line of information that will identify the record and then provide a detail view to show all the data in the record.

For example, in the contacts tableview, you have a tableview that shows the name of the contact and then a a detail view that shows the address, phone#, email etc.

TechZen
A: 

You can try

[cell.textLabel setNumberOfLines:5];

This would in combination with the heightForRowAtIndexPath will give you what you are after.

Jayant