我有一个视图,其中有一个滚动视图。我想检测触摸开始,移动等方法。我使用了这些方法。这些方法在滚动视图外部工作正常,但在滚动视图内部无效。告诉我为什么无法正常工作,解决方案是什么。
You have to Subclass UIView (as MyUIView)and Implement the touch delegate.
Then Add MyUIView to UIScrollView
Eg:
@interface MyUIView : UIViewController {
}
@end
@implementation MyUIView
//implement touch delegate here
}
Add this line in your main view
MyUIView *myUIView = [[MyUIView alloc] init];
myUIView.userIntarctionEnabled = YES;
[yourScrollView addSubView:myUIView.view];
Note : you can use UIGustures instead of sub-classing. The UIGestureRecognizer class is available to help with detecting and responding to the various UI gestures common on iOS devices
使用convertPoint: toView:
方法。
CGPoint *point = [yourView convertPoint:touchPoint toView:yourScrollView];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.