Make UICollectionView zoomable? - ios

Is there any method make the UICollectionView zoomable, i.e. when you pinch, all the cells can be zoomed in and out.
I can implement this in UIScrollView by returning the only subview of the UIScrollView from delegate method
- (UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView
Since UICollectionView is kind of UIScrollView, is there a way or work around to implement this? Does the UICollectionView has one direct subview that contains all cells?
Thanks

I think what you're asking for looks like what is done in the WWDC1012 video entitled Advanced Collection Views and Building Custom Layouts (demo starts at 20:20).
You basically have to add pinchGesture to you UICollectionView, then pass the pinch properties (scale, center) to the UICollectionViewLayout (which is a subclass of UICollectionViewFlowLayout), your layout will then perform the transformations needed to zoom on the desired cell.

Related

UITableview scroll whole cell height

Is it possible to let UITableview move up/down whole cell height just like date picker (not stop between the cell top and bottom)?
The class UITableView is a subclass of UIScrollView.
This means that, if the object you specified as your table view's delegate also adopts the UIScrollViewDelegate protocol, that protocol's methods will be called on it whenever the relevant scroll events happen on the table view.
You can use that timing to "fix" the table view's scroll offset in just the right way to simulate the snap-to-row-bnoundary behaviour you're after.
Some examples:
scrollViewDidEndDragging(_:willDecelerate:): Tells the delegate when dragging ended in the scroll view.
scrollViewDidEndDecelerating(_:): Tells the delegate that the scroll view has ended decelerating the scrolling movement.
Which methods to implement, and what exactly to do in their implementations, will depend on what effect you want to achieve. Play around and see.

UIScrollView in UICollectionViewCell gestures handling

I've seen people with similar problems here, but couldn't find any working solution. I have a UICollectionView, with fullscreen cells. I scroll the content horizontally (paging enabled). Each cell has a UIScrollView as a subview, which covers the entire cell. My problem is that when I use zoom-in functionality of a UIScrollView, I can't scroll from one cell to another unless I zoom-out to 1.0 scale or reach a border of a UIScrollView content. My idea was to use two-fingers pan gesture to scroll the collection view, so I could use one finger to scroll cell's internal UIScrollView. It doesn't work and I simply have no idea why. I can provide more details, but for now I don't know what might be important.

iOS - Use/pass gesture recognizer for multiple Tableviews or Collectionviews in a View(Swift)

I've got 2 (circular) UICollectionviews in my view, both are functioning but I want to use 1 swipe gesture for both views so when I swipe on the top collectionview, the bottom view should also swipe with the same speed and vice-versa. What would be the best way to achieve this?
This is my UIViewController:
both collectionviews should scroll whenever I scroll anywhere on this UIViewController. Any help would be very appreciated.
Set scrollView delegate of your collectionView's scrollView. UICollectionView is a subclass of UIScrollView.
Use scrollViewDidScroll method. In that method you can for example see contentOffset of one UICollectionView and then set contentOffset to the other collectionView's scrollView to that value.

Adding subview to UICollectionView - disables scrolling

I want to add a subview to a UICollectionView in order to make a left panel that scrolls with the collectionview.
Using
[self.collectionView addSubview:myView]
all touches become disabled and I can no longer scroll the view. I've read that adding a subview to a collectionView like this is bad practice.. is this true? Why does it disable touches from reaching the collectionView event when
userInteractionEnabled = NO
I'm trying to do this: imgur link by grabbing the frame position of the first cell in each section, and adding a dot with to myView with the same y value.
Thanks for any help!
Adding subviews using the addSubview: method to a UICollectionView is very bad practice. It can cause a lot of different problems in the normal behaviour of the CollectionView. It can obstruct the views underneath it, capture the touch events, preventing them from reaching the actual scrollView inside the CollectionView, etc. The subviews added using this method will also not scroll as the other elements in the CollectionView do.
The correct way to do what you want is to implement a new type of UICollectionViewCell for the dots, and compute their locations in the prepareForLayout and layoutAttributesForElementsInRect: methods. Basically you'll have either one or two cells in each row. Which ones will have two rows will be determined by you in the methods I've mentioned.
In fact, Apple's docs have a perfect example that's even more complex than what you're trying you achieve. You should check it out from this link.
May I know the purpose of that scroll view ? Because, if you're looking for a subview that displays only a label or image etc., You can use custom collectionview cell instead if I am not wrong... Hope it helps :) :)

UICollectionView inside of UIScrollView

I have a
UIScrollView
Labels
Labels
UICollectionView
I have disabled the UICollectionViews scrolling functionality, so I only want to scroll with the Scrollview. My problem is that I don't know how I can calculate the UICollectionViews height so I can update my UIScorllView. If it's many elements inside the UICollectionView, it's get clipped.
I have created this little HTML example to show what I'm looking for
http://jsfiddle.net/hDwPH/
Dummy code
So my suggestion would be to use a single UIScrollview. Create your own view (we'll call it A) with whatever you are trying to repeat in the Collection view and addSubview A to the UIScrollview over and over for however many times you want.
Another way that just came to mind would be to use entirely a collectionview create two collectionviewcells, one that has your labels and you only display it for the first cell and the other collectionviewcell for all the others

Resources