Multiple cell types in UICollectionView - ios

I had created two type of cells for my CollectionView, both are of different heights.
But when I run the app, the black cell is cut in half. I am unable to understand why. I tried changing the size of the cell, but it in turn makes the black cell over lap the cell below it. Please help with this.
Thanks

The size of the CollectionView item has to be changed dynamically. Kindly follow the following link to solve
UICollectionView - dynamic cell height?

Related

How to setup UICollectionViewCell margins correctly?

I'm setting up a new prototype for a project, and I need to use a UICollectionView. The thing is, I'm struggling trying to set the correct margins to my UICollectionViewCell, but it doesn't work the way I want.
Here is my problem. I have a UICollectionView showing 3 cells. I'm showing only one cell in every "page". The orientation is horizontal and I'm using pagination as well.
The problem is the last cell. What I need to do to show the right margin of the last (third) cell.
Here's the image. The first one and second one are fine. The third is has a problem.
I'm subclassing the UICollectionViewCell. I don't thing that's the problem, though.
Here's the UICollectionView configuration and settings.
The UICollectionView is a 280x280 square. And the UICollecitonViewCell is a 260x260 square.
Here's the UICollectionViewCell configuration.
No extra code to change UICollectionView or UICollectionViewCell dimensions. I', trying to do the whole thing using Storyboard.
Any advice?
Thank!
Well.. After testing again, and again, and again I realised how UICollectionView and UICollectionViewCell work.
In my above set up, I make 2 big mistakes.
1) In the UICollectionViewCell setup, I set Custom size. I changed to default instead.
2) In the "Section Insets", I changed the right value to 10.
Here's the final result.
:)

TableView Cell Not Showing Content and Not Responding To Commands

When working in the storyboard I can add labels and imageviews to a tableview cell but when I run the app they will not show. The only way I can get them to show is if they are in a stackview on a view within the cell. The cell will only not change colors on run time even if the cell's background color is changed in the storyboard. Is there any way I can fix this?
You should give us more insight to your project - that means your code, possibly your storyboard...
It's hard to tell what you did wrong when we even don't know what you did.
Did you connect your objects with outlets?
If you defined your own cells, did you selected them in storyboard?
How about your TableView Delegates?

UICollectionView: Reordering cells of varying, but fixed widths

I am trying to build a UICollectionView that consists of cells that are of fixed height and varying widths. The cells can either be 100%, 50%, or 25% in width.
I am creating these cells from a custom subclass, and then I am adjusting the size in sizeForIndexPath. My problem is that when reordering cells, I get a lot of weird visual glitches as the cells have their sizes adjusted rapidly as the index path changes.
Basically, I want the size of the cell to depend on the type of cell (or the content in the cell), not the index path of the cell.
What is the best way to handle this? I thought about using multiple classes for the different types of cells, but I can't set the width of the cell with a frame when initializing it. Any ideas?
Update: Here's a link to a video showing the bug I am trying to solve
http://d.pr/v/FTM8+
Try this tutorial. It for a table view but in the conclusion some recomendations for a collection view. I cannot try this tutorial now and garaunted it works for collection view but tomorrow I will do it.
Cheers.

Swift: Making UITableViewCells load from the bottom

I want to load messages from my UITableView from the bottom up.
The blue is my UITableView, and the green is my first cell in a tableview with only one cell. The default, and what I have right now, is a normal UITableView where the green cell is at the top of the blue tableview.
I've researched this online, and the best solution I've found is to make several empty clear colored cells, but that doesn't satisfy the programmer in me.
What is the best way to do this?
Update: Yes, with enough cells I can just scroll to the bottom. But I am asking for only a few cells, while maintaining the UITableView's height.
Update 2: Can I create a custom UITableView to implement this? I don't want to change my UITableView into a UICollectionView.

Collectionview CustomLayout

I want a collectionview cell should be the dynamic height. I am getting data from server and loading in to tableview inside collectionview cell. That cell height should be change according to the table cell height, I am getting till here. But the problem is The cells are not aligning from the top. see this pic. The cell should create from top. This is demo code. Thanks
If I'm understanding your problem correctly, try setting self.yourCollectionView.automaticallyAdjustsScrollViewInsets = false
You will need to extend UICollectionViewLayout. And then in the prepareLayout method, you will need to specify the calculated frames of every item of your collectionview.
There are two tutorials:
http://www.skeuo.com/uicollectionview-custom-layout-tutorial is a very good tutorial for custom layout.
https://github.com/betzerra/MosaicLayout and https://www.cocoacontrols.com/controls/rfquiltlayout is pretty much what you want. A related question about rfquiltlayout on stackoverflow is RFQuiltLayout and UICollectionView

Resources