国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

UIGestureRecognizer手勢(shì)操作

2019-11-14 18:17:51
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

UIGestureRecognizer類(lèi),用來(lái)檢測(cè),識(shí)別用戶(hù)使用設(shè)備時(shí)所用的手勢(shì),定義了所有手勢(shì)的基本行為.以下是UIGestureRecognizer子類(lèi),喲關(guān)于處理具體的用戶(hù)手勢(shì)行為。

單擊手勢(shì)

單擊手勢(shì)UITapGestureRecognizerUITapGestureRecognizer *singleTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(singleTap:)];    [self.view addGestureRecognizer:singleTap];//單擊事件-(void)singleTap:(UITapGestureRecognizer *)tapgestrue{    NSLog(@"單擊");}


雙擊手勢(shì)

UITapGestureRecognizerUITapGestureRecognizer *doubleTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doubleTap:)];    doubleTap.numberOfTapsRequired=2;    [self.view addGestureRecognizer:doubleTap];    //區(qū)別單擊雙擊手勢(shì)    [singleTap requireGestureRecognizerToFail:doubleTap];//雙擊點(diǎn)擊事件-(void)doubleTap:(UITapGestureRecognizer *)taggestrue{    NSLog(@"雙擊");}

輕掃手勢(shì)

UISwipeGestureRecognizer *swipeGesture=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipe:)];    //設(shè)置輕掃方向,默認(rèn)向右    swipeGesture.direction=UISwipeGestureRecognizerDirectionDown;    [self.view addGestureRecognizer:swipeGesture];//輕掃事件-(void)swipe:(UISwipeGestureRecognizer *)swipeGesture{    NSLog(@"輕掃手勢(shì)");}

//平移

UIPanGestureRecognizer *panGesture=[[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(pan:)];    [self.view addGestureRecognizer:panGesture];   //平移事件-(void)pan:(UIPanGestureRecognizer *)pan{    CGPoint point=[pan locationInView:self.view];    NSLog(@"%@",NSStringFromCGPoint(point));}

//長(zhǎng)按手勢(shì)

 UILongPRessGestureRecognizer *longPressGesture=[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPress:)];    longPressGesture.minimumPressDuration=2;    [self.view addGestureRecognizer:longPressGesture];//長(zhǎng)按手勢(shì)事件-(void)longPress:(UILongPressGestureRecognizer *)longPress{    //長(zhǎng)按離開(kāi)時(shí)一會(huì)調(diào)用一次,所以需要設(shè)置手勢(shì)狀態(tài)    if(longPress.state==UIGestureRecognizerStateEnded)    {        return;    }    NSLog(@"長(zhǎng)按超過(guò)兩秒");}    

//旋轉(zhuǎn)手勢(shì)

UIRotationGestureRecognizer *rotation=[[UIRotationGestureRecognizer alloc]initWithTarget:self action:@selector(rotation:)];    [self.view addGestureRecognizer:rotation];//旋轉(zhuǎn)事件-(void)rotation:(UIRotationGestureRecognizer *)rotation{    //根據(jù)旋轉(zhuǎn)的弧度獲得角度    float degree=rotation.rotation*(180/M_PI);    NSLog(@"%f",degree);}

 


發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 松桃| 尚志市| 客服| 桃源县| 临泉县| 固始县| 左云县| 咸阳市| 湖州市| 巴彦县| 石屏县| 西盟| 永平县| 锦州市| 梨树县| 霍林郭勒市| 古浪县| 梅州市| 德惠市| 当阳市| 五华县| 永州市| 永德县| 高淳县| 岢岚县| 通榆县| 汉阴县| 四子王旗| 湘乡市| 北京市| 苍梧县| 温州市| 昂仁县| 绥芬河市| 苍山县| 灌南县| 长治县| 乌鲁木齐县| 南城县| 寿宁县| 萍乡市|