Changing frame of one of two sections of UICollectionView - ios - ios

I am trying to configure my CollectionView to have one section be differently sized than the others. I have two sections. Lower part should show a number of cells simultaneously and the upper section should only show one cell at a time but be scrollable to reveal more cells one by one.
I tried to play with the .frame property of the CollectionView but obviously it is not the right approach as it changes the appearance of the whole view.
I also tried to retrieve the FlowLayout object and see if I can get it from there. Did not find a way.
Neither the section Insets are the answer so far ...

It is simple to use two uicollectionviews for upper and lower section, instead of using only one.

Related

iOS - Add border around a collection view cell and a view under it

There is a collection view cell and a view of the same size right under it.
Instead of separately adding two circle borders for both the cell and the view, I want to add one for them together (forming a rounded rectangle)
Is this possible?
If yes, how to handle the scrolling of the collection view?
Yes it is possible but tricky.
I'd suggest you really try to combine it into one cell to avoid lots of headaches.
If you can not then you need to toy with the collection view layout to get your cell to line up correctly with the view underneath and you need to figure out the scrolling as you indicate.
I've sometimes had to use two consecutive collection view cells that needed to align and it was terrible to get it right, thus I suggest try to solve this problem using just a single cell. FWIW the last cell in a collection view often shifts slightly compared to the others so I've sometimes added a blank cell last just so my second to last will align correctly.

Is is possible to control the speed and scrolling of a UITableView

I've got custom tableview cells that are 170 px tall. Including the table header I can see two complete cells and a portion of the third. When I scroll the tableview, the cells shift up but do not stop until a portion of the third is above the table.
Is it possible to change the way the table scrolls and allow me to see all of the third cell. A video illustrating the issue is available at https://youtu.be/iuhuR_wDe90
Images of the issue:
It seems you have enabled 'pagination' on your UITableView.
You can get rid of this in Interface Builder, in the Scroll View section there's an option called 'Paging Enabled' which should be switched off.
If you don't use storyboards, tableView.pagingEnabled = NO; will do the trick as well (though it is NO already by default).

UITableView fixed section with dynamic size

I am trying to implement something like this:
I have a UITableView with 1. "static" section, the total number of sections in the tableView can vary. I always want the first section (white area) to be visible to the user, the remaining sections should scroll underneath the first section. I have tried to implement this with two UITableViews, but since the (white area) can vary in size, I can't set a definite frame. I am using Storyboards with autolayout. At the moment the best solution I have come up with is the two UITableViews, but I need to find a way that I can resize the two tableViews according to the content of the white area and according to each other. The white area, one of the tableViews is containing a section with two rows, the first row is containing text that can vary in length and therefore needs dynamic resizing.
Any Idea how I can tackle this? Can I change the NSLayoutConstraints dynamically somehow?
If i understand correct, your first UIView rectangle if fixed, bottom table is scrollable.
To implement this, you should create typical UIViewController, add UIView and UITableView (programmatically or through an outlets). You should manage each view (tableView and UIView) separately.

How to create a layout like Featured page in App Store?

I'm new in iOS development. Based on my assumption, Feature page in App Store was created using a combination of UITableView and UICollectionView. But how to do that in theory and code? I know it's a bit vague, because it's quite hard to describe it, but I just need some people to help me explain it.
For this case I will try to use these naming:
1. Top section, it's a view which showing banners of apps, people can swipe it to view another banner.
2. Middle section, views which can be scrolled horizontally. (Best New Apps, Best New Games, etc).
3. Bottom section, starts from Quick Links to the bottom.
Questions:
1. The scroll indicator is starts from the root view's top guide, that's normal, but:
a. When we scroll it up, the bounciness is start from the middle section. How to do that? Is the top section and middle section is a separated view? But how can the scroll indicator is started from the root view's top guide if top and middle section is a separated view? (Separated view means that the views should have different scroll indicator unless it's actually subviews of UIScrollView).
b. When we scroll it down, there is nothing that floating. So it looks like that the whole page is a subview of a single scroll view but the bounciness is starts from the middle section. How to create that bounciness effect while only have one scroll indicator for the whole page?
2. In the middle section, there's a several collection view that has horizontal scroll direction. Is it the best way to create it like that is to use UITableView with cell that has UICollectionView inside it? It looks like it was created that way, but:
a. Is it the most efficient way to do that?
b. Because of the case in my first question is my source of confusion.
3. The bottoms section has a different separator from the middle section. The middle section has indentation while the bottom section doesn't. How can I do that if the case is it's a UITableView?
My whole question is just how to create a layout like that. If you cannot help me by providing me some sample codes that's fine, please just explain me the concept or theory of how to do that.
If the whole answer is just I have to create it using vertical/horizontal UIScrollView from scratch that's fine. I just want to make sure of that since I tried to avoid dealing with creating manual tiling.
OK, I think I finally found my own answer.
First, I need a UIScrollView to be root of the view. Then I set the contentSize to be a specific value.
The top section can be a UIPageController or a horizontal UIScrollView.
The middle section is a UITableView with scrollEnabled to NO and cells are static. The static cells (could also be dynamic cells) will contains UICollectionView. Since the scroll is disable, it will use the scroll from the parent UIScrollView. So that's why I can get the same bouncy effect in the middle section.
The bottom section is just another cell of a UITableView.
Thanks.
This might help you with implementing UICollectionViews in your UITableViewCell: http://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell
To make the first cell "float" in the TableView you could make sure that cell never goes out of screen in scrollViewDidScroll

UICollectionViewFlowLayout sections as columns rather than rows

I'm trying to create a UICollectionView of two columns (of potentially different lengths) with the property that when a cell is deleted the cells below (rather than the cells to the right) move up to take its place. I have considered customising the layout using layoutAttributesForElementsInRect etc but don't want to do this if there's an easier way.
Basically all I need is the transpose of the standard FlowLayout with each section a new column instead of a new row. Any advice would be much appreciated.
It is not possible using UICollectionView without customizing the collection view layout based on your needs. UICollectionViewFlowLayout is a line breaking layout that means, it places all your cells along a line and break that line to the bounds of the collection view one by one. So you can place two cells in a row by adjusting the cell size and section insects. Even though it wont allow you adjust the cell during the deletion as your need. Obviously the adjacent cell will take place the position when deleting a cell. Can you go with two collection views side by side instead of one??

Resources