久久久久久久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 可縮放?)
主站蜘蛛池模板: 欧美久久精品一级黑人c片 91免费在线视频 | 色婷婷综合网站 | 精品久久香蕉国产线看观看亚洲 | 久久精品国产一区 | 久久免费视频1 | 一区二区三区不卡视频 | www精品美女久久久tv | 99国产精品99久久久久久 | 精品伊人久久 | 亚洲一区视频在线 | 成人午夜激情 | 91黄在线观看 | 亚洲视频在线播放 | 亚洲精品中文字幕av | 黄a大片| 在线免费观看成人 | 国产精品一区二区三区四区 | 国产欧美一区二区三区在线播放 | av福利网站 | 黄在线免费观看 | 一区二区国产精品 | 狠狠久久 | 精品一二区 | 综合久久一区 | 91在线看片 | 久久中文字幕电影 | 综合色婷婷| 涩爱av一区二区三区 | 中文字幕高清av | 四虎成人免费视频 | 久草热8精品视频在线观看 午夜伦4480yy私人影院 | 国产一区二区三区四区在线观看 | 欧美影院 | 中文字幕在线观看第一页 | 美女久久| 福利社午夜影院 | 一区二区三区视频在线观看 | 精品在线一区 | 9久久婷婷国产综合精品性色 | 先锋影音资源网站 | 一级高清免费毛片 |