TableView in iPhone - iphone

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.

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;

To accomplish this the better way is to follow the customization of cell.You can increase the height of row using delegate method tableView:heightForRowAtIndexPath.
(you need to return the height as return 55). Then you can add a label to cell and then add text to label with specifying the number of lines in label according to your requirement.

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.

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.

You can try
[cell.textLabel setNumberOfLines:5];
This would in combination with the heightForRowAtIndexPath will give you what you are after.

Been asked many times. See:
How do I wrap text in a UITableViewCell without a custom cell
Setting variable UITableViewCell height

Related

Separate buttons in UITable without custom cell

Is it possible to have a UITable with cells that are all the same, each containing buttons that only effect that cell (based on indexPath.row I'm guessing), without having to make a custom cell?
I too need this, but I have a custom cell.
#kaylaGalway your method sounds like it could work for me, could you elaborate? As I have been searching for this answer for hours now (Swift 3)
You can design your table cells freely. It is possible to have a different cell for each and every row within the very same table.
When you have matching cell types for each row you can also add buttons (one or more) in these rows. They can also point to the very same function. With a clever usage of the 'tag' you can identify each individual button. Using the Indexpath.row you can naturally also identify the row in the table.

Customize column of table view

Is it possible to customize the column of table view.
By default table view contains 1 column, But according to my requirement I want 4 column in table.
Means I want table like we create in MS-word/excel.
Thanks.
http://dewpoint.snagdata.com/2008/10/31/drawing-a-grid-in-a-uitableview/
ad
http://usxue.is-programmer.com/posts/14176.html
will help you
No there is no such method to do that ..... but for sure u can make a subclass of UITableViewCell such that it has 4 parts in it and all parts are seperated by a fine line (a kind of bordered image as background will do the job). You can manage your data accordingly and it may create an illusion of MS-word/excel.
But I am sure you are aware of column and row of UITableView, so you can manage all your data is this format. If you want to represent data in tabular fashion like MS-word/excel you don't have enough space as width on iPhone and If you incorporate a tableView in a scroll view, two scroll will not be user friendly.
So i suggest you to go with TableView's native behaviour for such type of task.

How to make an never ending UITableView?

I have some options in an UITableView and want that the user can scroll forever. When the end is reached, I want to append the begginning so the user can continue to scroll.
How would I do that?
In tableView:numberOfRowsInSection: return some huge number, and act accordingly in tableView:cellForRowAtIndexPath: by returning same cells over and over.
You can also have limited number of rows, and at the end show a different cell - containing a button for user which he can use to append new rows. When that button is clicked you simply call [tableView reloadData] and provide more rows in table's data source.
Aren't you by any chance misusing the table-view for something it doesn't fit that well ? Maybe you would be better off using just a UIScrollView and reposition subviews as user scrolls over.
I think the only problem is how to trick in the method numberOfRows:. One possible solution is to return some big number here, for example, 10 000. Then, you set up a correct cellForRowAtIndexPath: to return based on your data's number modulo. For example, if you have 100 data entity, then you have to get the indexPath.row % 100

Is there another option to configure the height of an table view cell?

I need a way to alter the UITableView row height differently, but without implementing the delegate method -tableView:heightForRowAtIndexPath: because it causes me some serious performance problems in an indexed table with 15.000 rows.
Now the thing is, that every third table is 10 units bigger. than the others. These are a different kind of UITableViewCell subclass.
But I couldn't find a property in UITableViewCell that could help here. What could I do?
You cannot usefully set the cell's height from the cell class itself. The only options are that delegate method and setting rowHeight on the table view, which obviously applies the same height to all cells.
Looks like the docs acknowledge there are performance issues for that delegate when using more than 1000 cells or so.
Perhaps you can split you table in sections and set those larger cells as table section headers (you can specify a separate height for those). Then you will have to deal with the way section headers start to stack at the top of the table; I don't know for sure but you may be able to alter that behavior.

display a long string in a table row

i have a tableview which displays the result from the web service
the result fron the web sevice is in form of string array, where each string in the array is pretty long. It is like "1|123|JP Morgan|111|2000.0|Pending", similarly there are strings which i diplay in each row of the table.
but as you can see the string is very long, to display it in a single table row.
in the table view, i can just view first 3 ie "1|123|JP Morgan" the it shows.....
how can i display the entire string in the table
Your options are to make it smaller or make a custom table cell. To change the size, set the property cell.textLabel.font to a font of a smaller size (e.g. using [UIFont systemFontOfSize:10]. You may also want to change cell.textLabel.numberOfLines to something greater than 1.
To see more about making custom cells, read the Table View Programming Guide.
You can add a UILabel to your cell's contentView. If you do this, you can set the UILabel.numberOfLines to a number greater than 1. If you set it to 0, it will use as many lines as needed.