問題描述
我的 UIScrollView
有很多子視圖.當我滾動時,我想點擊要拖動的子視圖.有沒有辦法讓 UIScrollView
停止吞咽觸摸?或者當您取消滾動時是否可以開始新的觸摸(就像它滾動并且我點擊它一樣,子視圖也會被點擊以便我可以將其拖出)?
I have UIScrollView
that has many subviews. When I scroll, I want to tap on a subview which I want to be dragged. Is there a possible way to make the UIScrollView
stop from swallowing touches? Or is it possible to start new touch when you cancel the scrolling (like what it scrolls and I tapped on it, the subview will be tapped as well so I can drag it out)?
推薦答案
繼承 UIScrollView 并覆蓋 - (BOOL)touchesShouldCancelInContentView:(UIView *)view
方法.這是一個允許 uibutton 觸摸通過的示例:
Subclass UIScrollView and override the - (BOOL)touchesShouldCancelInContentView:(UIView *)view
method. Here's an example to allow uibutton touches to pass through:
#import "scrollViewWithButtons.h"
@implementation scrollViewWithButtons
- (BOOL)touchesShouldCancelInContentView:(UIView *)view
{
return ![view isKindOfClass:[UISlider class]];
}
@end
這篇關于如何阻止 UIScrollView 吞下觸摸的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!