How To customize different rows in UITableView - iphone

I want to create a page in iphone sdk which looks same as flight search result
problem is that each there are different number of stops some has 2 stops some has 1 etc. and not only leave flight detail but return flight detail can also be asked.
It must sorted on the basis of charges.
I am not getting from where I start
I make 3 custom cells
showing source n destination detail
the flight detail
to make separator between leave n return results
this is demo i have tried with fixed value! [1 row a SimpleTableIdentifier(background color not able to set) 2 and 3 row are 2 different CustemCell, there is separator custom cell too]
but I think i make it complex unnecessary
any tips and help will be apprecited thanks in advance.

Go like this make three customCell one for each of your three category
cell structure to show source and destination detail
cell structure to show flight detail
cell structure to make seperator
Now your UITableView will be a grouped tableView with numberOfSections = number to total flight you have to show
Each section will have three rows (if it has all three information available) else you can reduce the number of rows in any section by delegate method of UITableView named numberOfRowsInSection.

Try not to forget to give all different custom cells other dequeueReusableCellWithIdentifier's for re-usability.

Related

Multiple Collapsable Sections with non-collapsable sections divided by headers

So I have been scouring the internet but can't find the solution. Currently I have a tableview with collapsable sections, the rows within these sections are off course related to the section. I have two other categories that don't need these collapsable sections, these are just rows. Currently I have a segment control that has the following:
Category 1 (Collapsable sections with each a different number of rows)
Category 2 (Standard list of rows)
Category 3 (Standard list of rows)
Category 4 (all of the above)
Category 1-3 work fine. But I can't combine all in one view. I would like to have three headers with each showing their corresponding category. First header should show all sections that are collapsable. The other two just rows.
What I tried:
Using section count to give each category a header but this ends if giving a header to all sections individually.
Using section count to give each category a view.
Potentially, creating three TableViews for each category if all Segment is selected.
Can anyone help in the right direction to what would be the best solutution.
I don't think my code will help because I'm still not sure what method I should use.
I did make a drawing to show what I mean:
if anyone has an idea that would be fantastic, thanks!

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.

Best way to display data in rows and coloumn format

i am doing an app for iPhone which has to display the details of students of school i.e. their name,class name,marks in different subjects.I have to display the same in rows and columns format
Can anybody suggest me the best way to implement a 7 column table
If You only want display the information then in Custom UITableViewCell put 7 UILabels Horizontally depends on your UI.If you also want some action on them then put UIButtons in place of UILabel.

Can I drag sections in tableview as I can do it with rows?

I use
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath
toIndexPath:(NSIndexPath *)destinationIndexPath{
}
method for dragging and dropping rows within and across sections. Can I perform drags with sections as well?
It's probably conceptually (as well as technically) simpler to step back a level to a table view where each row corresponds to the sections of the table you want to re-order. Maybe you could invoke this with a "re-order sections" button, show the section-table-view, re-order, then impose that re-ordering on the detail table view.
I think if you try to do it all inside a single table, you're going to frustrate yourself and your users. My 2 cents.
-Mike
Old question, I know, but I just implemented something that does this myself so I wanted to share the answer in case it helps others who stumble across this.
My basic approach was to add a row representing the section to the top of each section. I also added a "Add a new section" row with editing style of UITableViewCellEditingStyleInsert at the end of each section to allow creation of new sections directly within the view. So, for each section the rows were like:
Row 0 = Section row (visually distinguished by setting different
background color)
Rows 1 to x = normal data rows
Row x+1 = "Add a new section"
(I have a couple of simple methods to translate between "edit mode indexPath" and "real data indexPath".)
For moving sections, the proposed move is checked in the UITableViewDelegate Protocol method tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath: to ensure that the section row has moved "far enough" (above or below another section row). The returned indexPath is clipped to either just above or just below the nearest section row (depending on if moving up or down) to give the user a visual indication of where it will be moved.
In tableView:moveRowAtIndexPath:toIndexPath: the section change is made in the data source, then a reloadData message is sent to the tableView to display the change. reloadData is used instead of moveSection:toSection: because with the latter, the data source and display would be out of sync due to the row move and would cause an exception.

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