Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

StevenMiles

macrumors newbie
Original poster
May 24, 2009
9
0
Hi,

I have a UIView subview that fills the lower half of the screen, and the UIView contains three UIImageViews.

I have processing that happens successfully when someone touches or drags anywhere in the UIView subview, but I don't want any touch events to trigger code if the touch happens outside of the UIView, in the upper half of the screen.

I discovered that if I set user interaction disabled in the main view that contains the UIView subview, then no events happen in the UIView subview either.

I can't figure out how to enable touch events just in the UIView subview but not on the entire screen. I hope I described my problem well enough.

/S
 
Well, you should put your touch-handling code (touchesMoved:withEvent: and those methods) in your "bottom-half-of-screen" viewController class. this way, touches in the upper half get recognized, but since there is no code that handles them, nothing happens.

or, if for some reason that is not possible, you could simply check in which view the touch occured (UITouch has a property "view")
 
Hi, BlackWolf,

Thank you so much for responding. I didn't realize I could have a view controller for the project, and another view controller for a subview. I'm a newbie, and I can't find an example of anything like that in the books I've read so far. Can you refer me to a reference on how to accomplish that?

/Steve
 
Hi, BlackWolf,

Thank you so much for responding. I didn't realize I could have a view controller for the project, and another view controller for a subview. I'm a newbie, and I can't find an example of anything like that in the books I've read so far. Can you refer me to a reference on how to accomplish that?

/Steve

you can have as many view controllers as you want, why shouldn't you?
don't know about an example, but you just create a view controller like always and do whatever you want with it and add your custom event-handling methods and stuff. the view controller has a property "view" that you can use to add the view as a subview. so, if you are in the superview-controller this would look something like:
[self.view addSubview:mySecondViewController.view];

edit: I guess an example, but maybe not a totally easy one, would be
http://developer.apple.com/iphone/library/samplecode/NavBar/index.html
which has a lot of viewcontrollers in it. actually, almost any application has more than one view controller.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.