SimplyKiwi
SimplyKiwi

Reputation: 12444

Disable touch events on Superview only?

I have a subview on the screen that is loaded from a XIB, I need to disable touch events ONLY on its superview while not touching the subview in the end. How would I do this? Also, I am using iOS.

Thanks!

Upvotes: 0

Views: 1750

Answers (3)

Srikar Appalaraju
Srikar Appalaraju

Reputation: 73688

This is how you can go about doing this -

  1. Go to interface builder & select your superview (for which you want to disable touches).
  2. Open right navigation bar. At the bottom there is a checkfield called "User Interaction Enabled". You can unmark it. Of course you can go about doing this from code too. But this is more graphic. This screenshot might help. See bottom of the image...

enter image description here

Upvotes: 2

Baby Groot
Baby Groot

Reputation: 4279

In XIB, rather than using all other views as subview, u can just use superview at same level and set its usertouch interface as FALSE.

Upvotes: 1

Iphone Developer
Iphone Developer

Reputation: 163

I am also new to iphone development but htis piece of code helped me out when i tried to move only UIImage view.

you can apply cahnges on this code if you are using buttons or labels in your view.

if ([touch.view isKindOfClass:[UIImageView class]])

{
    imageDemo.center = touchLocation;
}

Upvotes: 1

Related Questions