Is there a way to exit the current view group while using pan gesture in ios? - ios

So I have a horizontal scroll view at the bottom of my screen which contains child views. I would like to drag a view from the bottom and snap it to a defined position on the top. But while dragging the view, it only moves about inside the scroll view. Is there any way to exit the scrollview and get the view outside it?
Layout of the app (I want to take the items from the bottom and snap them to the positions on top):

When you try moving views coordinates with drag, it will only move on its superview, i.e. your bottom scroll view.
If you wanted to drag your button outside of your scroll view then you need to have a trick here.
When user started dragging the button, hide it.
Add the same layout button on main screen on exact position.
Move the newly added button on main screen where ever you want.
Once you drop it, remove the old scroll view button.
It will look like you dragged the same button on main screen but under the hood it was a different logic.

Related

How to add Button+ScrollView in Swift together?

I would like to create a level menu in swift.
I have a ScrollView and an image inside the ScrollView .
I would like to add a button which stays at the same place when the ScrollView scrolls.
If I put the button on the same level as the Scrollerview, it would work but the image inside the
ScrollView covers the button. If i put the button inside, it starts to move as i scroll.
How can i scroll the image and leave the button at the same place?
You should put the button on the same level as the ScrollView but above in the element list.

Objective C: Pan gesture only move parent view while all the subviews stay

I have a custom UIView that displays some text content.
On top of text content, I have many UIViews look like sticky notes.
The main text content view, which is parent view, can be moved to the left or right side of the screen with pan gesture.
The problem is that sticky note UIViews, which are subviews of the content view, do not move when parent view moves.
When parent view is panned, everything should move together.
How can I do that?

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.

UIScrollview, other controls, not scrolling

I have an app which shows two images housed within a UIScrollview.
The scrollview is of size (320, 530), underneath it is an imageview size (320,38), this acts like a dock at the bottom of this screen, ( in fact it has to be there at the bottom of all screens in this app).
As it stand the scrollview works fine and the images switch from one to anothr when the user
moves the scrollview.
The problem is, I need the scrollview height to go all the way down ( from 530 to 568), and end up behind the dock imageview, when I change its height and the height of images within it, it just stops scrolling.
Is this impossible in scrollviews? does it have to have all of its screen real estate as top view?
Any solutions for this?
Thanks.
Update :
so I worked on the alpha and the image constraints, and the bottom imnage is located properly,
still the scrolling is not functioning.this is the latest code with changes.
http://ge.tt/4LYJGWl/v/0?c
thanks.
This is certainly possible. Add a full height scroll view to the controller's view, then add the small image view to the bottom. In the scene list at the left move that image view up so it's directly underneath the main view, which will make it a subview of that view rather than the scroll view (you'll then need to move the scroll view up above the image view so the image view will appear on top). You'll probably have to change some constraints to pin it to the bottom, and give it an alpha value less than 1 so the scroll view will show through.
After Edit
This is the screen shot of the scene from your updated code:
You only have one view that's directly under the main view, your scroll view. Compare that to my image.

moving a view under finger

I have a view-chain; the first view is in the second, the second is in the third and so on.
I want to move the top most view under my finger and I did some logics to handle this in touchesBegan:touchesMoved:...
The problem is that each view has different gestures and if I try to move the top most view, the views behind it also respond to the moving. Is there any way to disable the gesture except the top most view when I am trying to move it?
Also I do not want the top most view to go outside the border of its immediate parent view, and I did some logics in the touchesMoved: to reset the center or the top-most view. The effect is not good as this approach allows the view to go outside, but will move it back once it went out.
How about just creating and turning on a disable flag at the bottom views while adding the top most view to it's parent view, if you don't want the bottom views to respond to their own gesture recognisers?

Resources