Which the better way to make carousel view in swift with open - animation (expanding)? - ios

I need to make carousel view in swift with "opening-animation".
First of all, I have created scroll view, after that have created subViews with my customView, maked my scrollView paged-enabled, and it's okay, but I need to make it expanding by swipe gesture. I added animation, but this view can't be higher than scrollView height, so I need to make this width and height (after gesture) like viewController's view height and width. And, it's the problem.
What's better way to do this?
Example screen:
BeforeGesture
Second example screen: after up-swipe gesture

I think you will need to handle it using the UIPanGestureRecognizer gesture which will give you the better control on all the different states of pan (drag began, drag ended). In your drag ended state you can handle the logic of increasing the height of scrollview and after that add the animation to show the expanded view with animation effect.
Let me know if you need any further help.

Related

Is it possible to drive a table/collection view's scrolling from gestures inside another view?

Suppose there are two UIVIew subclasses in two different regions of the screen.
The first UIView subclass is a table or collectionView
The second view is a simple UIView.
Is it possible for gestures inside the second view to be "carried over" to the first view so that for example, a swipe up gesture in the second view would make the table/collection view scroll up ?
In WWDC 2012 Session 223: Enhancing User Experience with Scroll Views, Apple engineers explained that you can take a scroll view's panGestureRecognizer and add it to a different view to make that other view control the scroll view's scrolling.
Note that UITableView and UICollectionView are subclasses of UIScrollView.
So if you can put your table view and your second view into a common superview, you can move the table view's panGestureRecognizer to the superview and it will detect touches on both subviews.
[commonSuperview addGestureRecognizer:tableView.panGestureRecognizer];
The best way to achieve that is to encapsulate your 2 views in a another view and to add the GestureRecognizer on the motherView.
This way when the gesture triggers, with the location of the touch you can figure out if it started in one view or the other and you can track the move all the way to the second view.

Vertical Sliding of xib while we drag using finger using Objective-C

I have a Main view(currently displayed view).
AnotherView is added as a subview to a scrollview.The initial position of this AnotherView has to be in such a way that the bottom of this another view appears on the top most portion of the MainView.
Now,when I drag the AnotherView's bottom portion downwards,AnotherView should get displayed as SLIDING from top to bottom with the speed I drag it.
When I stop dragging,the sliding also should halt.
If I release the dragging after half of the screen,the sliding should continue to bottom of the screen.
How could I achieve this ?
You should use UIPanGestureRecognizer.
AnotherView should be in front of main or put it to front in Pan recogniser's function on UIGestureRecognizerStateBegan.
If UIGestureRecognizerStateChanged change anotherView frame accordingly to this movement. You can get movement by [panRecognizer translationInView:self.view] which returns CGPoint. And check if Another view is already after half of the screen. If you pass half of the screen, just use animateWithDuration to finish movement on UIGestureRecognizerStateEnded.
So another view doesn't need to be inside scrollview.
As far as I understood, you want to make something similar to sliding out menu. http://www.raywenderlich.com/32054/how-to-create-a-slide-out-navigation-like-facebook-and-path
There you can find example how to use pan recognizer to slide view by dragging.

Slide up view in a horizontal UIScrollView?

I currently have a horizontal scrollview where the next content is partially displayed. For some of these views, they need to be able to pull up and expose more content. What's the best way to build this sort of interaction? I see that I can capture scrollview events via the scrollview delegate, but I'm not sure where to go from there.
Extend the scrollview height up to whatever height you want the view to be able to move to/expand.
Then, add a UIPanGestureRecognizer to the scrollview, and detect when the movement is 'up', and move the views as necessary.

How can I add Two GestureRecgonizer in Single View

I have a small view (View Frame Size : 100,0,20,30), i want to add two gesture recognizer one is UIPanGestureRecognizer and another one is my own custom GesuterRecognizer "CPPinGestureRecognizer".
UIPanGestureRecognizer is used for drag the view in horizontally.
Example: the dragging bounds are :(100,0 to 320, 0)
CPPinGestureRecgonizer is used for enlarge the view in vertically with the same width.
Example: (enlarge view height up to user drag the view)
Now the problem is both gesture are working together and i want to check if the view dragged horizontally means want to fail CPPinGestureRecognizer, if the user dragged vertically means want to fail UIPanGestureRecognizer.
how can i achieve this.
Thanks in advance.
Gesture recognizers can have a delegate (UIGestureRecognizerDelegate), and this protocol has 2 methods: gestureRecognizer:shouldRequireFailureOfGestureRecognizer: and gestureRecognizer:shouldBeRequiredToFailByGestureRecognizer. You can use those to not allow one to be recognized while the other one is currently being recognized.

ios move touch event between two uiscrollview

I'm building an iOS layout which consists of a UITableView and a UIScrollView. The UIScrollView is inside a table cell of the UITableView and can be scrolled both horizontally and vertically. The diagram below shows this situation. If the user begins scrolling down/up on the UIScrollView the scrolling event should trigger setContentOffset of the table view, and not setContentOffset for the scroll view while the top of the scroll view will be on the dotted line (it's constant height). Then a scrolling touch event should trigger setContentOffset for the scroll view, not for the table view.
In another case: When the user starts scrolling on the table view, it should trigger setContentOffset for the table view, until the scroll view reaches the dotted line. Then the scroll view should handle setContentOffset.
My problem is how to transfer touch events between the table view and the scroll view during one sliding action.
This sounds like one of those cases where you want something quite specific and custom. So trying to do something clever with the gesture recognizers won't be enough.
The main problem is that the ways you can control gesture recognizers such as with gestureRecognizer:shouldReceiveTouch: and gestureRecognizerShouldBegin: only affect the start of the gesture (or for new touches, not ongoing ones), but you want a single ongoing gesture to transition between controlling each view. So for this reason I think you will need to place a large transparent view over your entire screen with a pan gesture recognizer on it and in your handlePan method decide which view you want to adjust and then call setContentOffset directly on that view. You can use the translation of the pan recognizer and the existing content offset to calculate the new one. I know this isn't very elegant, but I can't think of another way to achieve the effect you want.
I'm not sure if this is going to work, but you could try doing something like this:
Option
self.scrollView.panGestureRecognizer = self.tableView.panGestureRecognizer;
Option
[self.scrollView addGestureRecognizer:self.tableView.panGestureRecognizer];
Option
[self.tableView.panGestureRecognizer requireGestureRecognizerToFail:self.scrollView.panGestureRecognizer];

Resources