久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

iPad 應用程序的 UIScrollview 中的兩指輕掃

Two finger swipe in UIScrollview for iPad application(iPad 應用程序的 UIScrollview 中的兩指輕掃)
本文介紹了iPad 應用程序的 UIScrollview 中的兩指輕掃的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

其實我想在 UIScrollview 中實現左右滑動.我有內容大小(768,1500)的滾動視圖.我已經嘗試過了,但問題是有時它沒有檢測到滑動并在那里執行滾動.所以現在我想禁用兩指觸摸滾動.

Actually i want to implement swipe left and right in UIScrollview. i have scrollview with content size (768,1500). i have tried this but problem is that sometimes its not detecting swipe and perform scrolling there. so now i want to disable scrolling on 2 finger touch.

swipeGesture = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(nextswipedScreen:)] autorelease];
swipeGesture.numberOfTouchesRequired=2;
swipeGesture.direction = UISwipeGestureRecognizerDirectionLeft;         
[self addGestureRecognizer:swipeGesture];

swipeGesture = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(previousswipedScreen:)] autorelease];
swipeGesture.numberOfTouchesRequired=2;
swipeGesture.direction = UISwipeGestureRecognizerDirectionRight;            
[self addGestureRecognizer:swipeGesture]; 

我已經為此嘗試了自定義滾動視圖,但 touchesBegan 方法有問題.它不是每次都打電話.即使我嘗試了這個但無法停止 UIScrollview 中的兩個手指滾動.

i have tried custom scrollview for that but i have problem with touchesBegan method. its not calling every time. even i tried this but not able to stop two finger scroll in UIScrollview.

for (UIGestureRecognizer *mgestureRecognizer in _scrollView.gestureRecognizers) {     
        if ([mgestureRecognizer  isKindOfClass:[UIPanGestureRecognizer class]])
        {
            UIPanGestureRecognizer *mpanGR = (UIPanGestureRecognizer *) mgestureRecognizer;
            mpanGR.minimumNumberOfTouches = 1; 
            mpanGR.maximumNumberOfTouches = 1;
        }
    }

如果您對此有任何解決方案或替代方案,請告訴我.

Let me know if you have any solution or alternative for that.

推薦答案

我也遇到了同樣的問題;我需要禁用兩指滾動,以便檢測到向左或向右滑動的兩指.這是我設置滾動視圖時所做的:

I had the same problem; I needed to disable two-finger scrolling so that I could detect a two-finger swipe to the left or right. Here's what I did to set up my scroll view:

- (void) setUpGestureHandlersOnScrollView:(UIScrollView *)scrollView {
    // set up a two-finger pan recognizer as a dummy to steal two-finger scrolls from the scroll view
    // we initialize without a target or action because we don't want the two-finger pan to be handled
    UIPanGestureRecognizer *twoFingerPan = [[UIPanGestureRecognizer alloc] init];
    twoFingerPan.minimumNumberOfTouches = 2;
    twoFingerPan.maximumNumberOfTouches = 2;
    [scrollView addGestureRecognizer:twoFingerPan];

    // set up the two-finger left and right swipe recognizers
    UISwipeGestureRecognizer *twoFingerSwipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleGestureFrom:)];
    twoFingerSwipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
    twoFingerSwipeLeft.numberOfTouchesRequired = 2;
    [scrollView addGestureRecognizer:twoFingerSwipeLeft];

    UISwipeGestureRecognizer *twoFingerSwipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleGestureFrom:)];
    twoFingerSwipeRight.direction = UISwipeGestureRecognizerDirectionRight;
    twoFingerSwipeRight.numberOfTouchesRequired = 2;
    [scrollView addGestureRecognizer:twoFingerSwipeRight];

    // prevent the two-finger pan recognizer from stealing the two-finger swipe gestures
    // this is essential for the swipe recognizers to work
    [twoFingerPan requireGestureRecognizerToFail:twoFingerSwipeLeft];
    [twoFingerPan requireGestureRecognizerToFail:twoFingerSwipeRight];
}

處理程序方法應如下所示:

The handler method should look something like this:

- (void)handleGestureFrom:(UISwipeGestureRecognizer *)recognizer {
    if ([recognizer numberOfTouches] == 2) {
        // do whatever you need to do
    }
}

這篇關于iPad 應用程序的 UIScrollview 中的兩指輕掃的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

how to set scrollview content size in swift 3.0(如何在 swift 3.0 中設置滾動視圖內容大小)
Stop a UITableView from automatically scrolling(阻止 UITableView 自動滾動)
iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
using iOS 6.0 SDK and building for iOS 5 Target causes UIScrollView setMinimumZoomScale to fail when running on iOS 5 simulator(在 iOS 5 模擬器上運行時,使用 iOS 6.0 SDK 并為 iOS 5 Target 構建會導致 UIScrollView setMinimumZ
Create partial-screen UIPageViewController programmatically(以編程方式創建部分屏幕 UIPageViewController)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
主站蜘蛛池模板: 久久国际精品 | 成人精品国产一区二区4080 | 国产精品视频久久 | 日本男人天堂 | 亚洲综合免费 | 亚洲精品91 | 国产激情在线观看 | 日日综合 | 亚洲国产成人精品久久久国产成人一区 | 亚洲激情一级片 | 欧美日产国产成人免费图片 | 午夜男人天堂 | 欧洲一区二区三区 | 欧美日韩综合 | 欧美偷偷 | 一区二区三区免费 | 亚州春色| 国精产品一区二区三区 | 99伊人网| 久久亚洲国产精品日日av夜夜 | 成人欧美一区二区三区在线播放 | 精品91久久久 | 一级h片 | 日韩欧美在线视频 | 亚洲电影成人 | 91久久电影 | 亚洲成人av| 最新免费视频 | 国产精品1区2区 | 久久久久国产一区二区三区四区 | 日韩中文视频 | 中文精品视频 | 国产精品日韩欧美一区二区三区 | 久久伊人青青草 | 九九视频在线观看 | 免费黄视频网站 | 久久亚洲一区二区三区四区 | 亚洲夜射 | 欧美精品一区二区三区蜜臀 | 久久99精品久久久久久噜噜 | 久久久国产一区二区三区四区小说 |