Touch events in a UICustomview is not working - UICustomview - ios

i created a custom view
i had an another view in a viewcontroller which is stackview act as a parent view for customview.
when i displaying view dynamically to that stackview(parent view). view is appearing but Button touch events are not recognizing.
when i displaying customview in a superview - button events are working.
i checked all views userinteraction enable is true.
i dont have any idea whats going on.
any solution

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.

How to pass a tap to view depending on if dragging/scrolling or just tapping

I have a UIScrollView with another view behind it that has buttons. The buttons cannot be on the scroll view, they must be behind it. I am using the pointInside method to pass taps to the buttons view behind the scroll view if that is where the user is tapping. However, I don't want to pass the tap to the buttons view if the user is trying to drag/scroll. If that is the case I want it to scroll the scroll view instead of pass a tap to the buttons.
How can I accomplish this?
UIScrollView has a panGestureRecognizer property. Use the pan gesture's state to determine if you have to pass touches to your button or not.

UITextField inside a UIView thats animated on touch dismisses the view and shows the keyboard

I have a structure for my UIView object and have form elements within it. I run the application and the program is in such a way that when i click a button inside the UIView, it moves the current frame upwards. But thats not the problem.
My phonenumberfield is of type UITextField which is inside a UIView and that UIView is a part of the parent View. I have one button called submit and a segment control on the Parent UIView. But when i touch the phonenumberfield or any textfield type on the parent view, the parent view gets dismissed and keyboard shows up. Its weird I cant understand what the problem is because can't debug this. :(
I had a problem with the constraints for Auto Layout I had set for my scrollview and managed to fix the constraint and my view started scroll. To animate the view, I set a constant height from the top of the parent view and animated the view by changing the constant which did not affect the keyboard anymore.

UIButtons not working in Scroll View

I have a Scroll View with a View (content view) inside of it. I've added two buttons to test. The Scroll View scrolls fine but the buttons within the content view are not clickable. I've seen plenty of posts saying this issue happens when they programmatically add UIButtons to the View, but I am not doing this. Here is my exact process:
Drag the Scroll View onto the main view. Add 4 constraints
Drag the Content View onto the Scroll View. Add 4 constraints.
Add 2 Buttons (one high and one low to test scrolling) to the Content View.
This is all I am doing, no code at this point. Is there anything else I have to do to allow the buttons to be clicked? Here is a screenshot of my xib:
Update:
When hooking the button up to a simple IBAction and logging a message, it turns out it IS being pushed and working properly. However, when the button is pushed, the button isn't changing colors like it should (its "pressed" state is not appearing). Any ideas why?
First make the button to custom type
Select button from storyboard then on right attributed inspector change its "state config" to whatever you need like Highlighted, selected, Disabled and default and choose the colour for each state.
Now you can see the colour change on that button.
A UIScrollView first needs to know whether or not you are going to scroll before letting the touch pass to its child views. If you want the child views to get the touch immediately, set the UIScrollView's delaysContentTouches to NO.

iOS iPhone mapview with slide-up scrollview - How to set up?

I am struggling with how to set up the following view arrangement. Not sure what viewcontrollers I should use. Should I use a container view (I'm only supporting iOS6+)?
I have a screen that contains a mapview (and view controller) that is working great. I want to add a view to this screen that slides up from the bottom to partially cover the mapview. This subview will be a scrollview and will have a small handle that is visible even when closed that a user can drag up to open or down to close. When this drawer view is open, the user can "page" left and right through a list of objects and the map will update accordingly.
I don't need any help with the map view or scroll view individually, only how the generate this screen with the multiple views.
Everything I have done thus far is via Interface Builder.
Thanks!
You could create a empty xib (UIViewController) and add this Xib file as subview of the main view. Next add a gesture recognizer to the main view (https://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizer_basics/GestureRecognizer_basics.html), on the right gesture slide the subview up (http://www.raywenderlich.com/2454/uiview-tutorial-for-ios-how-to-use-uiview-animation).

Resources