これに関するさまざまなスレッドを読みましたが、必要な正確な解決策を提供してくれるものはありませんでしたが、かなり近いものになりました
ページングUIScrollingView(xibを介して作成)を含む最上位のUIViewControllerがあります
UIScrollingView は、ユーザーがページをスワイプすると、さまざまな viewController に交換されるダミーの viewcontrollers の配列を読み込みます。
これらのサブビューの 1 つには多数のスライダーが含まれています - 通常の問題: ユーザーがスライダーを少し見逃すと、代わりにページをスクロールします。
サブビュー内で、画面を部分的に覆うスライダーの後ろに UIView を配置しました: 'uiviewblocker'
アイデアは、この「uiviewblocker」がスライダーのすぐ近くの領域でのタッチを食べるが、uiview の外側のスワイプは親 UIViewController によって処理されるということです。UIView 'uiviewblocker' を重複した UIViewController 'MyView' にサブクラス化して、それを検出できるようにしました。
私はここまで...
親 UIScrollView:
scrollView.delaysContentTouches = NO;
サブビュー UIViewController
-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
NSLog(@"touchesBegan");
//[self.nextResponder touchesBegan: touches withEvent:event];
UIView *touchView = [[touches anyObject] view];
if ([touchView isKindOfClass:[MyView class]]) {
NSLog(@"funky shit");
[super touchesBegan:touches withEvent:event];
//[self.delegate touchesBegan:touches withEvent:event];
//[self touchesBegain:touches withEvent:event]; // View does not respond: crashes
//UIView *parent = self.view.superview;
//[parent setCanCancelContentTouches:YES]; // UIView does not respond
//UIScrollView * parentScrollView = (UIScrollView*)self.superview; // Superview not in structure
} else {
NSLog(@"normal shit");
}
}
これで、クラス 'MyView' をテストすることで、ユーザーが安全領域の UIview に触れていることを検出できますが、親 UIScrollView に中止するように指示する方法と、そこに触れるだけの方法がわかりません。