开发者

iPhone SDK - Forwarding touches from a UIViewController to a subview

开发者 https://www.devze.com 2023-03-17 23:17 出处:网络
I have a UIViewController with a subclass of UIView on it called customSubView1. Then on customSubView1 I have another subclass of UIView called customSubView2.

I have a UIViewController with a subclass of UIView on it called customSubView1. Then on customSubView1 I have another subclass of UIView called customSubView2.

I can capture开发者_开发百科 all the events for touches on all the subviews when I put touchesBegan/touchesMoved/etc in the UIViewController class. But I want to be able to process them in my custom classes.

I keep reading that the UIViewController class needs to 'forward' the touch events to the subviews, but I haven't been able to find any example code to do this. Does anyone have any idea?

Many thanks, Brett


Implement the touches... methods in your views.


Try to set for you UIView object userInteractionEnabled property:

myUIView.userInteractionEnabled = YES;
0

精彩评论

暂无评论...
验证码 换一张
取 消