سؤال

I have a smaller UIView as a subview to the main UIView on my UIViewController. This smaller UIView also has an image and a couple of labels.

What I want is for the user to touch this smaller view (anywhere on this view or it's contents) and then segue to a new UIViewController.

I have added a Tap Gesture to the smaller view and set a segue from the Tap Gesture to the UIViewController I want to show next.

However this only works if the user touches only a space on the view that does not have the labels or image and "User Interaction Enabled" is checked. If the image or labels are touched, nothing happens, and if "User Interaction Enabled" is unchecked, nothing happens.

I've done this entirely from the storyboard, and only implementing a prepareForSegue method.

Is there something I'm missing? Any help would be greatly appreciated, Thanks!

هل كانت مفيدة؟

المحلول

Remove the user Interaction from all the Labels and images(uiimageview has userinterraction set no by default). If other elements have user interaction enabled, they will catch the touch; if they have user interaction set to no, the next view in hierachy will catch it.

Very important is to remove the interaction from the labels and imageviews, not the view you are touching

نصائح أخرى

Why not just place a transparent button over the UIViewController & all its views that triggers the segue. That way you don't need to worry about any views under it

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top