I have a Hierarchy like this: UIScrollView -> UIView -> UIButton
I would like to click the UIButton but it appears the ScrollView is eating up all the events. How can an event be passed down to the UIButton?
I had the exact same issue. What solves the problem is to remove the UIView layer. Build you hierarchy like that UIScrollView -> UIButton.
I put the code from UIView in a subclass of UIButton.
in the same case - when i scroll 1 page down, buttons are not response. buttons above, witch i see after viewDidLoad() are works fine.
try to set userInteractionEnabled = YES for your UIView
Related
I have a UIImageView as subview in my scrollView.
I want to be able to pan up/down on UIImage to adjust the color of the UIImage.
Also I want to be able to pan/zoom around the image(that's why I implemented scrollView).
I have an adjustColor IBAction UIButton which adds the UIPanGestureRecogniser as target and executes the function below:
func panned(gesture: UIGestureRecognizer){
...
}
My problem is that the adjustColor button is ignored by scrollView's scroll behaviour.
If I delete the scrollview and add the UIImage, the adjustColor button activates the color adjustment function and the gestures work perfectly.
On the other hand, if I have the scrollview and the image as subviewimage, my adjustColor button has no functionality.
Any help would be appreciated.
Thank you.
Make sure to connect the UIGestureRecognizer IBOutlet with scrollview.
I am trying to capture a touch through a UILabel, but am having trouble. Here is my scenario.
I have a UIButton as a subview of a UIScrollView. I also have a UILabel as a subview of the same UIScrollView. The frame of the UILabel overlaps that of the UIButton, and thus (as far as I can tell) occludes the UIButton from being pressed.
I am trying to create a scenario where the user can touch through the UILabel (it has a transparent background, so the button is completely visible - less the labels text).
Is this possible?
I know touches behave differently when there is a UIScrollView involved. Is that impeding the touches?
Anyone have any advice?
Cheers,
Brett
myLabel.userInteractionEnabled = NO;
Creating transparent UIButton on top of UILabel that too inside a UIScrollView is a design issue for me. If you have to do it then you don't have a choice. It won't work seamlessly though. Don't expect users not to complain. If I don't see a button there and scrolling through the view accidentally triggers button action then I am irritated.
It is possible to create such UI.
I want to create a big UIScrollView, its contentView should contain more than 30 UIButton. Positions of these UIButton are not rectiligne and cannot be create 'programmaticaly' so I've placed all these UIButton on a UIView manually. I zoom/dezoom and scroll all over my UIScrollView fine BUT here is my problem : UIButton created offscreen is not accessible, I mean I can't click them (only UIButton created in the CGRect(0.f, 0.f, 320.f, 480.f) can be click.
Any suggestion ?
Create a view, put a scrollView inside that view, and place your buttons on the scrollView. While adding buttons and moving them around, be certain that they're always inside the scrollView by looking at the object hierarchy in interface builder.
You can slide the scrollView around as you place things, no need to zoom. As long as your buttons are children of your scrollView it should work fine.
How can I add a UIButton in a CALayer and hookup the touch event?
A CALayer is not an event responder, so trying to hook it up to a touch event handler will do nothing.
If you want a button that actually works on top of a CALayer, put that CALayer into a UIView (which is a subclass of UIResponder), and add a UIButton to that view (so it can get added to the event response chain).
In iOS, all UIViews own and draw themselves through a CGLayer. You probably want to create a UIView for your button to go in. Everything you can do with raw CGLayers, you can do with UIViews.
i am creating a dropdown button in my app. Like a pop-up control which is available in webapps. so when i click on a button, a new UIView containing a UIPickerView appears. i user beginanimations and commitanimations for dispalying and hiding the UIView. the new uiview is half the size of the scrollview.
I want that whenever the new uiview appears, the size of the scrollview should alter so that the i can scroll through the entire view. something like, when a keyboard appears, we reassign the size of scrollview, so that we can scroll entire view.
So how will i know, when the uiview appears. Is there a notification for beginanimations and commitanimations like for keyboard (UIKeyboardDidHideNotification)
thnx in advance.
if the subview you create and show have a viewController, -(void)viewWillAppear method of the viewController will be called on every appearance of that view.
In that method, you can somehow get the superview (for example calling nextResponder method) and resize the superview according to your needs.
Hope that helps.