輕量級應用開發之(11)手勢

2022-02-02 18:22:32 字數 3096 閱讀 6552

ios開發中手勢識別有六種:

輕擊手勢(tapgesturerecognizer),

輕掃手勢 (swipegesturerecognizer),

長按手勢(longpressgesturerecognizer),

拖動手勢(pangesturerecognizer),

捏合手勢(pinchgesturerecognizer),

旋轉手勢(rotationgesturerecognizer),

uitapgesturerecognizer *tapgesture =[[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(tapgesture:)];

tapgesture.numberoftapsrequired = 1; //

點選次數

tapgesture.numberoftouchesrequired = 1; //

點選手指數

[self.view addgesturerecognizer:tapgesture];

//輕擊手勢觸發方法

-(void)tapgesture:(uitapgesturerecognizer *)sender

注意:設定手勢起作用的元件可以進行互動。

//設定長按時間

longpressgesture.minimumpressduration = 0.5

;[self.view addgesturerecognizer:longpressgesture];

//長按手勢觸發方法

-(void

)longpressgesture:(id)sender

}

說明:長按手勢的常用狀態如下

開始:uigesturerecognizerstatebegan

改變:uigesturerecognizerstatechanged

結束:uigesturerecognizerstateended

取消:uigesturerecognizerstatecancelled

失敗:uigesturerecognizerstatefailed

uiswipegesturerecognizer *swipegesture =[[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(swipegesture:)];

//設定輕掃的方向

swipegesture.direction = uiswipegesturerecognizerdirectionright; //

向右[self.view addgesturerecognizer:swipegesture];

uiswipegesturerecognizer *swipegestureleft =[[uiswipegesturerecognizer alloc] initwithtarget:self action:@selector(swipegesture:)];

//設定輕掃的方向

swipegestureleft.direction = uiswipegesturerecognizerdirectionleft; //

向左[self.view addgesturerecognizer:swipegestureleft];

//輕掃手勢觸發方法

-(void

)swipegesture:(id)sender

if (swipe.direction ==uiswipegesturerecognizerdirectionright)

}

uipinchgesturerecognizer *pinchgesture =[[uipinchgesturerecognizer alloc] initwithtarget:self action:@selector(pinchgesture:)];

[self.view addgesturerecognizer:pinchgesture];

////捏合手勢觸發方法

-(void

) pinchgesture:(id)sender

//結束後恢復

if(gesture.state==uigesturerecognizerstateended)];}

}

uipangesturerecognizer *pangesture =[[uipangesturerecognizer alloc] initwithtarget:self action:@selector(pangesture:)];

[self.view addgesturerecognizer:pangesture];

//拖動手勢觸發方法

-(void

) pangesture:(id)sender

uirotationgesturerecognizer *rotationgesture =[[uirotationgesturerecognizer alloc] initwithtarget:self action:@selector(rotationgesture:)];

[self.view addgesturerecognizer:rotationgesture];

//旋轉手勢觸發方法

-(void

)rotationgesture:(id)sender

if(gesture.state==uigesturerecognizerstateended)];}

}

知識點:

1、 xcode 分屏

commond + option + 回車

輕量級B S應用開發引擎 NoahWeb

同事介紹,說一款bs開發引擎比較強大,處理表單之類的比較不錯,今天找來看看。幫助 http docs.noahweb.noahweb是一套b s輕量級快速開發引擎。解決b s專案開發過程中有關專案設計 後期維護 應用程式安全 需求變更等方面的瓶頸。傳說,天神為了懲罰人類,決定毀滅世間一切。諾亞方舟承...

輕量級爬蟲開發(二)

二 簡單爬蟲架構 動態執行流程 三 url管理器 管理待抓取url集合和已抓取的url集合 目的在於 防止重複和迴圈抓取。url之間往往迴圈指向的,如果不對url進行管理,爬蟲就會不斷的抓取這些url,最糟糕的情況兩個url互相指向,則我們將不停的抓取這兩個url管理器,形成死迴圈。功能 url管理...

python 輕量級爬蟲開發2

urllib2 python官方基礎模組 request 第三方包更強大 url urllib2.urlopen url coding utf 8 import urllib2 直接請求 response urllib2.urlopen 獲取狀態碼 print response.getcode 讀取...