Is there a way to stack up the cells of a table side by side? - iphone

What i mean by this is that cell1 would be top left. Cell2 would be top right. Cell 3 would be below cell 1, cell 4 would be below cell 2 etc..
Is there a way to do this?

UITableView does not support this out-of-the-box. You can fake it, but you might also want to try using something like AQGridView.

The UITableView only allows for one column, so it's really more of a stack or list than a table. To do what you are talking about you will need to create a custom UITableViewCell either in Interface Builder or code that "fakes" columns through layout, but you will only ever have one cell per row.
From the Documentation:
A table view in the UIKit framework is
limited to a single column because it
is designed for a device with a small
screen.

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.

Can I really have just one column in UITableView?

From the docs:
A table view in the UIKit framework is limited to a single column because it is designed for a device with a small screen.
Have look in the developer docuementation A Closer Look at Table-View Cells how to setup multiple columns in a table view cell.
Yes... unless you add subview in cell that looks like more than one column...
i.e 2 label in each cell with same size and horizontally aliened can look like Table with 2 column...
What about putting another tableview next to that one and synchronize the movement (scrolling)? :)

how to split a tableview cell into two?

I like to create a cell like contacts's add instant messages table view, with two cells to select: "AIM" and "home".
May be I can use the custom table cell as the cell's content view, but the table view framework always treats
one table view' cell as a whole, for example ,how to respond to did select row at index path message?
I'm pretty sure that Contacts is using a single cell.
The illusion of two cells is created by a custom cell that contains two buttons each configured to look like a tableveiw cell.
To get the same effect as Tweetie's split cell, create a custom cell and add a Segmented Control and create title and detail labels

TableView in 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