Increasing the width of UITableViewCell in a grouped TableView layout - ios

I am trying to get rid of the cell margin on the left and right of a set of cells within a group.
I have looked around and have found this question/answer
but this seems like it could cause plenty of problems down the track.
I also tried changing the cell.indentationWidth and cell.indentationLevel but these seem to change the indentation within the cell, not the cell itself.
Is there an Apple approved way of changing these cells to stretch the width of the Tableview??
Thank you in advance, your help is much appreciated.
Scott

Do one thing. add label or any other control in this and then add that in your UITableviewcell.
Then you can give whatever format you want according to your need.

Related

UITableView scroll on top of cell (or how to keep a cell static)

Recently I've been trying to implement the following behavior in my own app:
As you see, when you scroll the table view up, the first cell remains at its place while others scroll up and overlap it.
Have been searching for a solution for a couple of days and so far I've only found solutions that involve using headers. But the issue is that headers "stick" to the top whereas I need first cell to stay static.
Also had an idea about using a top constraint to keep the cell at place but don't quite understand how to approach this type of thing.
Any ideas how to implement that? Any help will be much appreciated!

How to get this image/text iOS layout from Apple?

I encountered this image on Apple's UI Design Do's and Don'ts:
Of course the UI on the left is the one I am shooting for, my question is what is the best way to go about getting this UI on the left? My initial thought was to use a static table view, with the top cell being the image and the cell below it but I came up with two problems with that approach:
How would I get that little water droplet image to span across both cells?
How do I make sure that the text field below the image is always the right length no matter how much text is put in (i.e. resizing the text field and the cell depending on the amount of text)?
My second thought was to use a UIScrollView and put the image at the top, constrain the water droplet in between them and then contain a text field below it, but then:
How would I make sure that the text field always the right length no matter the amount of text put in?
It is pretty impossible to constrain these items in a UIScrollView, how do I properly constrain this in a UIScrollView?
Why not use a UITableView, and make your cell in the interface builder that can be called through a reuse identifier. And each cell would have the image along with the relevant information that's required. This would fix your first option since you would be able to place the water droplet image over your image and your text.
For your second issue, making sure the cell is of correct height can be done by giving the UITableView dynamic height.
For example, you wouldn't need to insert a heightForRowAtIndexPath function on this tableview, and you can also define:
tableView.estimatedRowHeight = 100; //Can be any value really, but giving a reasonable estimate is helpful
tableView.rowHeight = UITableViewAutomaticDimension;
Also, your the textView you want to use shouldn't be set with any fixed width's or height in the interface builder.
TableView Image . Your imageView would be set up somewhat like the blue section in this picture (but fitting the entire width of the screen instead) and your textView would be like the red one. They would all fit in one cell and would make it much easier to organize than using 2 separate cells for one set of content, and you wouldn't have to get into the hassle of setting up the UIScrollView.

UITableView height for dynamic cells

In my current project i'm trying to display data in a table View, however the former view does not take up the whole screen just a part of it. It's number of cells depends on an external json and the height of the cell is dynamic. Sadly there is no inbuilt way to use auto-layout(at least i think there's not) to expand the tableView depending on it's cells.
In the following picture there's an example of how one of these table views should look like:
And here's an example how the table view looks like using the autolayout:
Is there a way to expand the tableView to it's full size?
I've tried to follow various other questions but none have fully helped me, for exampled i've tried to this solution which sadly did not help me :[, creating a subclass of uitableview and overriding its intrinsicContentSize did not do the trick either.
Any help is much appreciated.
-Jorge :]

Uitableview showing row behind HeaderView ios

I'm working on UITableView.
In that when there is one row in the tableview at that time I'm getting weird. The first row hides behind headerView of UITableView.
As you can see in below image
This is what happening. I'm using autolayout and having constraint also. I can't understand where exactly the issue is.
It seems that you have transparent headers - in case you have sticky headers, this might give you some problems when scrolling.
Your problem probably lies in the header height - check if the height your tableview returns for the header in the first section has the right height (and not 0 or 1 pixel).
Thanks #ALL For giving your answers to my question.
Actually there was constraint problem. I gave the constraint priority to low. and this causes the issue.
I changed it with Required. and it works now perfectly.
Thanks again.
this might happen if your view's height for header is larger than the headers size.
Or it might happen if your cell is implemented in .xib and the contents are going above the coordinates of the visibility.
If you can post the implementation code and snapshots of your interface it might help us to give you more appropriate answer

How to enable scroll in UICollectionView?

I’m still learning to develop in iOS and Swift so I apologize beforehand if my question is too simple.
I have created an UICollectionViewController to show a matrix of elements. My issue is that the width of the screen is not wide enough to fit all the columns in a single row, so the excess of them are shown in another row below. Instead of this, I’d like to enable the horizontal scroll so the user can scroll to see all the columns in one single row.
I know UICollectionViewController already contains UIScrollView so I guess this should be as simple as to change a setting in the .storyboard but I couldn’t find it after many trial-errors :(
I guess it is related to the "Flow" layouts setting and that I need to handle a custom one, but don't know how exactly.
Would anyone be so kind to please help me? I haven’t attached any code because I’m using a pretty standard/out-of-the-box implementation of UICollectionViewController but if you want me to add anything, just let me know, please.
Many thanks in advance for any help!
I found the answer to my issue perfectly covered on this post:
https://www.credera.com/blog/mobile-applications-and-web/building-a-multi-directional-uicollectionview-in-swift/
It's definitely to do with your UICollectionViewLayout — that tells the collection view where everything should go. The collection view simply picks its scroll behaviour appropriately.
A UICollectionViewFlowLayout is a specific type of layout that fills one row column to the size of the enclosing view, then moves on to the next. So it does one-dimensional scrolling. Does that fit your use case?
If so then you should just be able to set the scroll direction on the flow layout.
If not then you'll need to write a custom subclass of UICollectionViewLayout that implements the layout behaviour you want.

Resources