Press and swipe up to delete a UIView - objective-c

I'm wanting to make a UIView which acts similar to the iOS home button action where you can swipe a UIView with a gesture upwards until it is off the screen at which point it is deleted.
Although I can achieve the ability using a standard gesture, it does not give much UX feedback and would like to clone the ability to swipe upwards and make the UIView inline with the touch.
I'm wondering how to replicate or clone this ability where you can press and swipe upwards and the UIView will move in accordance to touch and delete.
thanks

Related

Ios 6 news feed (hidden page)

I want to create a hidden page on top of main screen (like iOS 6 news feed) and a button at the top-right corner. When people push it or hold it and swipe toward downside, the hidden menu will appear. Honestly I don't have any idea about it.
If you want to have more complex events than just a tap on a button you should be looking at using a UIGestureRecognizer. For the types of interactions you're describing you will likely need 2 recognizers - UILongPressGestureRecognizer for the tap and hold, and then a UIPanGestureRecognizer for the downwards swipe. You might be able to use a UISwipeGestureRecognizer rather than the pan but I'm not sure if a swipe needs to start with an independent tap from the long press.
Good resources for learning about gestures are:
Gesture Recognizer Basics - Apple
UIGestureRecognizer Tutorial from raywenderlich.com

UIButton not responsive while scrolling

I have a subview with a UIButton added to a UIScrollView.
The button is working perfectly as long as the user isn't scrolling.
If the UIScrollView is still scrolling when the user clicks on the button, it just stops the scrolling instead(like if a row had been clicked).
Anyone know how to fix this?
First, make sure this really is the behavior you want - iOS users are used to scrolling views and touching to stop them with a tap without triggering button presses. Non-standard behavior (even when you think its better then the standard behavior) can be confusing to users used to how things work in other iOS apps - it can violate their mental model. Ok, note of caution over.
So how do you fix this? UIScrollView delays sending touch events until it knows if those touches are scroll events. You problem is a user tapping is a scroll event when the UIScrollView is moving. Two possible solutions:
Stop the UIScrollView from delaying any touch events it gets. You can set any scroll views delaysContentTouches to NO, which will stop the delaying action and should allow your buttons to be tapped while scrolling. You can read about it in the UIScrollView class documentation. You will also want to read up on canCancelContentTouches there as well.
Subclass the UIScrollView to add your own logic about where touch events should go. Here is a blog post that discusses how to do this.

UIPanGestureRecognizer with UIPageViewController

I am using a UIPageViewController to display certain content. I want to be able to display additional content when the user pulls down on the page using a UIPanGestureRecognizer. I can't seem to figure out what I should add my gesture recognizer to such that it does not cancel any of the pageviewcontroller's actions.
One of the apps I worked on has functionality similar to this. It shows a full-screen UIPageViewController, but if the user drags down on a ribbon on the top right corner, it will slide the whole thing down to reveal a view behind (for settings and other stuff).
I think your problem is that the built-in gesture recognizers are for the page turns. So what you'd want to do is either have something to drag on (such as the ribbon on the top left in my app) that will have its own gestures. OR you can iterate through the gesture recognizers that are assigned to UIPageViewController and get the one that matches the PanGesture, then override it with your own functionality to either delegate the event to the UIPageViewController or do the slide down, based on the type of pan.
Hope that helps.

ios simulator: simulate swipe and drag

I have a UIView within a UIScrollView. When i want to simulate the drag event on the UIView, swipe event on the UIScrollView is being triggered.
As per the documentation , there isn't much of a difference between swipe and drag.
Swipe
1- Place the pointer at the start position.
2- Hold the mouse button.
3- Move the pointer in the swipe direction and release the mouse button.
Drag
1- Place the pointer at the start position.
2- Hold down the mouse button.
3- Move the pointer in the drag direction.
On an ipad I can use two fingers two swipe and one finger to drag. Now, how do i go about doing something similar on the simulator; drag instead of a swipe?
Edit 1:
I should have been clearer first up. Anyway, my problem is that the mouse drag is firing the swipe instead of drag, thereby scrolling the scroll view instead of passing on the drag event to the UIView contained by the scroll view.
I am on macbook pro. Two-finger swipe on the touchpad is being ignored. Touch and drag is causing the same thing as mouse-drag.
Thanks
See Jeff LaMarche's quick note on how to do this. It's documented in the same page you're reading, but Jeff's explanation is clearer.
If you want to simulate a two-finger gesture in the iPhone simulator, hold down the option key. You will get two dots on the screen instead of one. The two dots will default to pinching - if you bring the dot closer to the center of the screen, the other dot comes toward the center, making it easy to simulate a pinch in or pinch out.
If you want to do a different two-finger gesture, get the two dots the distance apart that you want them to be, then hold down the shift key, while still holding down the option key. That will lock the position of the two finger presses together so you can do, for example, a two-finger swipe.
see this documentation below:
iOS Simulator User Guide
Just use the mouse to drag the view, aka, left click the view then move the mouse
I ended up disabling the scrolling from the UI and added two buttons to scroll the scroll view. Since this is a work around only for the emulator, I have used #ifndef to hide the buttons while building for the device.

iPad Gestures with UITableView

I am using a UITableView to display a list of products in an iPad app. I would like to make this list scroll up and down, not only by swiping the finger, but also buy flicking the iPad vertically downwards (to scroll down a bit) or upwards (to scroll up a bit). I don't know what this iPad gesture is called and how to implement it with a UITableView. Can someone please explain or provide me with some code/tutorial?
Thanks.
You need to use the accelerometer for that (it's not a gesture, a gesture in a movement on the screen with fingers).
Have a look at the UIAccelerometer doc, you will find some nice example for what you're trying to do :
http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/MotionEvents/MotionEvents.html#//apple_ref/doc/uid/TP40009541-CH4-SW5
Hope this helps,
Vicent