[英]UISwipeGestureRecognizer for UIImageView in UIScrollView
[英]UISwipeGestureRecognizer and UIScrollView
我有一個垂直滾動視圖(不可能水平滾動),並且默認情況下我的標簽欄是隱藏的。 但是,您可以通過向上滑動屏幕底部來向上拉動標簽欄。(內容需要大量垂直空間)我的困境是:我希望能夠檢測到底部的向上滑動手勢我的滾動視圖的區域,而滾動視圖沒有向下滾動。 因此,我正在考慮在該底部區域放置透明視圖,以僅檢測到向上滑動。 但這有一個問題,盡管該視圖是透明的,但我所有的觸摸事件都被該視圖攔截,而沒有轉發到滾動視圖。
是否只能將水龍頭前進到我的滾動視圖,所以例如,我仍然可以按下當前在滾動視圖底部的按鈕?
我知道奇怪的問題,但是在有效的解決方案中我找不到類似的問題。
我的scrollview代碼:
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 30, 320, self.view.frame.size.height - 50)];
scrollView.showsVerticalScrollIndicator = YES;
scrollView.tag = 0;
scrollView.backgroundColor = [UIColor clearColor];
scrollView.delegate = self;
scrollView.maximumZoomScale = 1.0;
scrollView.clipsToBounds = NO;
scrollView.minimumZoomScale = 1.0;
scrollView.scrollEnabled = YES;
scrollView.pagingEnabled = YES;
scrollview.contentSize = CGMakeSize(320, xxxx);
我的透明視圖代碼:
UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc]
initWithTarget:self
action:@selector(showTabBar)];
swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
UIView *swipeLayer = [[swipeLayer alloc] initWithFrame:CGRectMake(30, self.view.frame.size.height - 80, 260, 40)];
[hideButtonSwipeActions addGestureRecognizer:swipeUp];
[hideButtonSwipeActions setBackgroundColor:[UIColor clearColor]];
//[hideButtonSwipeActions setUserInteractionEnabled:NO];
...
[swipeUp release];
非常感謝您的幫助:)
也許您是否使用觸摸(0,480)的坐標來跟蹤視圖底部?
您是否嘗試過將底部UIView的userInteractionEnabled屬性設置為NO? 它仍應允許您的滑動識別器正常工作,但是它應阻止視圖吞噬正常的觸摸。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.