How can I achieve rowspan in UITableView - ios

Please see image below, the image is currently done in HTML and CSS, I want to achieve similar result in UITableView, in some cells I want to show banner advertisement so I will to do some sort of rowspan for 3 cells, any clue how can I achieve this?
Please note the data is coming via webservice and it have scrollable pagination implemented, so making one custom cell containing group of cell ideas wont work, let me know how to achieve this, thanks.

Check this question.
In a few words - move every cell to its own section and implement methods heightForHeaderInSection and viewForHeaderInSection for your tableView

Related

I want to hide header view and detailed cell from the tableview, how could I achieve this?

Hide/Show header view and detailed cell from the tableview, how could achieve this? Advance thanks to any answers
I have some option based on that wanna hide and show the deatils contained cell and header view from the uitabeview cell. Please any one can help me. Also how can access tableview cell from outside dalegate methods to fix out this?
if you are using tableView viewForHeaderInSection section or heightForHeaderInSection section
the method you can easily put condition when to show or when to hide hope it'll help you!

Looking for the best scroll-view solution

I want to learn and implement the most suitable/simple solution to display dynamic data (JSON) in three lines and an active (clickable) download icon. Screenshot is attached
I would be glad to get your ideas and advice!
Thanks
UITableView is the way to go, as you can reuse a custom cell you define. And to add to that, UITableView's cells are loaded lazily and are reused. You can use a UIScrollView but if you have a lot of rows it can horde your memory real fast. In your case, a UIScrollView can be used as well, but if you plan on expanding, UITableViews would be the choice. All in all, go with a UITableView + a custom UITableViewCell
If you have array of data like this, the best way is using UITableView class. With UITableview, you can custom your UITableViewCell on the fly

For UITableView in UITableCellView method cellForRowAtIndexPath not called, but numberOfRowsInSection called

I am working on a existing project.
The project has one screen where details of an orders are displayed.
Every order has order items. So, naturally a table view is used to display order items. This works fine.
Now, the system has been extended in that way that every order item can have 0 or more toppings. If there are toppings for order item, they also need to shown in a list.
So, the approach I took is to try and implement a table view which will be responsible for showing order item toppings inside order item cell.
I've read about this approach and people say that it is possible.
The problem I have now is that for toppings table view in order item table view cell, the numberOfRowsInSection method is called, however the cellForRowAtIndexPath is not called at all.
I have read about this issue and the people say that is has to do with table view frame not being set correctly.
I've setup the order item with toppings cell in Interface Builder with AutoLayout.
I (think) all the constraints are in place in order for cell to render it's content and height correctly.
However, from the screenshots it can be seen that the toppings tableview is not rendered at all.
Anybody has an idea of what might cause the table with not to render?
Any help, thoughts, comments are appreciated. Thank you.
The problem seems to with your UITableViewDelegate and the way you want to achieve automatic height for your cells.
In heightForRowAtIndexPath you return UITableViewAutomaticDimension, which actually is equal to -1.0. If you look at that function's description in documentation you will see
Return Value
A nonnegative floating-point value that specifies the height (in points) that row should be.
Now, if each of your rows have negative height, then the table view has nothing to display - hence cellForRowAtIndexPath is never called.
TL,DR
You were almost there - UITableViewAutomaticDimension should be set to UITableView.rowHeight, not returned in heightForRowAtIndexPath
toppingsTableView.rowHeight = UITableViewAutomaticDimension
Also, remove the functions heightForRowAtIndexPath and estimatedHeightForRowAtIndexPath

Table header view is swiped to the left when deleting a cell

First off, sorry if this is a duplicated question but after reading several posts with similar issue, I wasn’t able to find a clear solution.
The problem is what the title states: I have a pretty basic tableview, with only one section and a tableheader. When I delete one row, the table header also gets swiped to the left at the same time with the row being deleted.
I guess the solution is to return false in canEditRowAtIndexPath when I know it is the header calling, but I don’t know how to differentiate it from the rest of rows.
I tried tableView.cellForRowAtIndexPath but didn’t work, I guess it is because the header cell is not really part of the tableview as the normal cells are. In fact, I don’t know how to get the indexPath of my header cell. I also thought about tagging the header cell but, again, I don’t know how to get it back in canEditRowAtIndexPath.
Many thanks in advance!!
This may happen if you are using an UITableViewCell instead of an UIView in viewForHeaderInSection method. Please verify it.
If you have only one section and you don't really need a sticky header, you could also add the UIView to the tableView.tableViewHeader property. Please check https://stackoverflow.com/a/5442005/3211512 for an example.
I think, allo86 is right. Your header may be a UITableViewCell. However, I would suggest a little different approach. If you are having only one section then set an UIView on top of your Table view(outside of the table) but if you are going to have multiple sections, then set UIViews as headers accordingly for any section for which you want to have a header.

UITableViewCell- controlling movement

When editing my UITableView, I give the option to move cells to reorder the data. However, The top two cells in the table are cells that give information about all of the cells in the table, and I dont want the user to be able to move information cells into that section. Here is a picture of the problem:
The user shouldn't be able to drag the cell titled 'This is bad!!!' into the section with the 'Total:' and 'New Group...' cells. Is there a way to control this functionality? I haven't seen a delegate method that does this, but I could have missed one.
Edit: oops! I just saw that someone else has asked the same question on SO, so I'm going to post the link and close this question. Thanks #fzwo for your help.
How to limit UITableView row reordering to a section
tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath: from UITableViewDelegate is what you're looking for.
In your concrete case, you could also display the header information in the actual tableView.tableHeaderView. This scrolls like an ordinary cell, but isn't a cell. It would probably also make sense from a UI perspective, because it is something different than your ordinary cell content.

Resources