国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 宁陵县| 临城县| 溧阳市| 吴江市| 佳木斯市| 营山县| 娄烦县| 安丘市| 紫金县| 灌阳县| 阿拉善盟| 海口市| 梁平县| 洪泽县| 麻阳| 大埔县| 涡阳县| 高清| 广昌县| 马龙县| 庆云县| 什邡市| 文安县| 海门市| 周至县| 高密市| 资中县| 漯河市| 汕尾市| 竹山县| 龙岩市| 介休市| 中西区| 泸溪县| 东海县| 武义县| 连州市| 广汉市| 亳州市| 武义县| 丰城市|