我有一個垂直滾動視圖(沒有水平滾動可能),我的標籤欄默認隱藏。但是,您可以通過在屏幕的底部區域向上滑動,將標籤欄向上拉(內容需要很大的垂直空間) 我的困境是:我希望能夠檢測到向上滑動的手勢我的滾動視圖的底部區域,沒有滾動視圖向下滾動。所以我在考慮在底部區域放置一個透明的視圖,以便只檢測到這一點。但是這樣做的問題在於,雖然該視圖是透明的,但我的所有觸摸事件都被該視圖攔截,並且不會轉發到滾動視圖。UISwipeGestureRecognizer和UIScrollView
是否有可能只向前滾動到我的滾動視圖,所以我仍然能夠,例如,按下當前在我的滾動視圖底部區域的按鈕?
奇怪的問題我知道,但我無法找到工作解決方案的類似問題。
我的滾動視圖代碼:
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];
非常感謝您的幫助:)
我真的不明白你在問什麼。你需要在scrollview的底部有一個透明的視圖,這樣你可以在它上面滑動? – Martol1ni
種。我有一個全屏滾動視圖,只能垂直滾動。現在想象一下,您只能在窗口底部實現向上滑動手勢。因此,我在滾動視圖上放置了一個透明視圖來接收滑動手勢,但它不會將正常的觸摸事件轉發給滾動視圖 - 多數民衆贊成在問題。 – christopher