Nested UITapGestureRecognizers - iphone

If I have several views stacked one on top of the other (all subviews of each other) where each one has a UITapGestureRecognizer attached to it.
How can I make sure that the highest visible view received the gesture and not the furthest ancestor?

The tap gesture is only valid for the current view. Further the frame of your current view(-controller). You can create a blank view over the hole screen and put in there your current view lets say 200x200 px. (essentially it is both in the same view)
Now all gestures should respond to your topmost view-controller. The bad thing about that: you can't access the views below anymore.

Related

How to pull a view from one corner of the app?

I would like to create view that could be pulled from one corner to take full screen (like the iphone status bar that can be pulled from top).
Could you just give me an idea how to accomplish that.
Thanks
Put a small view into the corner of the screen that acts as your handle.
Add a UIPanGestureRecognizer to that view.
When the gesture recognizer's action method gets called, move the handle and the view you want to present according to the movement of the user's finger.
When the gesture ends (because the user has lifted their finger off the screen), decide whether the movement was large enough to bring in the new view or not (e.g. if the user dragged the view over >30% of the screen, you move it in, otherwise you move it back out).
Animate the view into its final position.

Progressively reveal and slide UIView down from behind another UIView

I have a rectangular, menu-style view (view 1) laid across the window approx 100 px down (i.e. there is space above it in the window), and need to animate drop-down content (view 2) appearing lower down the screen from view 1. I need the animation to start at the bottom boundary of view 1 - much as with the iOS 5 notification pull-down, except from a specific point further down the screen.
I can't simply slide view 2 in from off screen, since for various reasons I can't overlay a UIView that would hide its motion until it reached the lower edge of view 1.
I've checked out this answer - Programmatically reveal a UIView - but I don't believe it's appropriate since I want the menu to slide, not be revealed from a static start point. And, as pointed out, I can't "hide" the sliding view with another view.
How do I slide down view 2 so that it is revealed as it emerges from the lower boundary of another view, similar to the io5 notification pull-down?
Contain both subviews in a superview with it's bounds clipped. So you'd have your superview (let's say app window), and within that a view (with bounds clipped). Let's call this a container view. This container would originate at whatever Y coordinate your current inserted/always visible view does, but it's height would extend tall enough to encompass the fully-expanded "sliding" third subview.
So within your container view, you'd place your first always visible view (view 1) at coordinates 0x 0y, and then you'd insert your sliding view (view 2) beneath that, with the frame y offset for view 2 set accordingly and at sufficient negative value to hide it completely by means of the over-layed view 1 and the clipped bounds of the container view.
As the user drags (or whatever means you use to disclose your 'sliding' view), the 3rd view slides down from below the always present view, but always stays within the overarching clipped view. Viola.

UIButtons located in a UIView underneath interfering

I have a UIScrollView over the main view of the view controller. UIScrollView contains some UIButtons (detail disclosure type) and a floating UIView -- all managed by only one view controller.
The floating UIView also contains its own UIButtons (custom, not rounded type). User is allowed to hide the floating UIView, or move it to a new location.
I found that the UIButtons contained in the UIScrollView (parent) are interfering with (preventing) tapping of the UIButtons contained in the floating UIView whenever these UIButtons overlap. If partially overlapped, only the overlapped area is a dead zone. I tried explicitly bringing the floating UIView to the front by issuing this message:
[self.myScrollView bringSubviewToFront:myFloatingView];
-but the problem does not go away.
The interference goes away if I keep the UIButtons of the parent hidden. But, this is not what I want.
Any suggestion will be appreciated.
Thanks you
A button can not interfere in the way you described. I think it something else.
All of the times I have had similar issue have been because subviews were taken outside the bounds of their parent views. The rule is:
If a subview is outside of its parent view's bounds it will not receive touch events.
This isnt explicitly stated in the docs but you can infer it by reading sections of the touch event guide.
I think what might be happening is that you are moving the floating UIView outside of its parent bounds.
It might not be it, its just a suggestion.

UIScrollview with paging and interaction

I am trying to wrap my head around how this would work. I want to create a horizontal scrollview consisting of "tiles" that are added and that you can scroll through (paging). On each tile will be a main image and other various smaller images that will act as buttons and launch popovers and such. I understand that I can create my "tile" as a uiview subclass programmatically or in a viewcontroller which then can have it's view added to the main uiscrollview. My question is where do I detect touch events of the small button-like elements in each tile? Would the main viewcontroller that manages the scrollview be the one that would handle the touches of the subviews' subviews?
You would detect the touch events for your tiles in whatever view handler you have them in. Basically you would have one view with a scroll view on it, then you would create another view that would have your tiles, within the view that contains your tiles is where you would handle the touch events for them, but you will have to keep track of which "Page" you are on to know what actions should be performed.
This is the best example I have found on using the page controls.

How do I animate through a bunch of "paged" views in a UIScrollView?

Say I have a bunch of views in a UIScrollView and I want each one to appear on the screen, one at a time, how do I do so?
Assuming your views are screen size, position them next to each other and set the pagingEnabled property to true, make sure the contentSize of the scoll view is wide enough for all of the views and then the user should be able to swipe through them one view at a time. You could do it automatically with an NSTimer if you don't want the user to have to swipe.