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

首頁 > 系統(tǒng) > iOS > 正文

(ios)屏幕觸摸總結(jié)

2019-11-14 20:44:06
字體:
供稿:網(wǎng)友

1  屏幕觸控實現(xiàn)(單擊 雙擊)

  [self becomeFirstResponder];     //允許多點互動     self.view.multipleTouchEnabled=TRUE;

實現(xiàn)事件部分

#PRagma mark-#pragma mark touch - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{     //觸摸開始   }- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{    //移動    }- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{  //結(jié)束 UITouch *atouch=[touches anyObject];    if(atouch.tapCount>=2)    {        //雙擊    }    else if(atouch.tapCount==1)    {           //單擊    }}- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{}

2 手勢識別(UIlabel 點擊事件實現(xiàn))

  //設(shè)置圖片的點擊事件    UITapGestureRecognizer *recongnizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTapFrom:)];recongnizer.numberOfTapsRequired=1;     self.img.userInteractionEnabled=YES;    [self.img addGestureRecognizer:recongnizer];}-(void)handleTapFrom:(UITapGestureRecognizer *)recognizer{      [self updateDisplayValuesWithTip:@"tap" tapCount:1 touchCount:1];}

 

 

3 屏幕晃動實現(xiàn)

//AppDelegate 中實現(xiàn)- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{    application.applicationSupportsShakeToEdit = YES;}//或者代碼中實現(xiàn) [[UIApplication sharedApplication] setApplicationSupportsShakeToEdit:YES];//ViewController 中實現(xiàn)下面方法- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0);{}- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0){    if (event.subtype == UIEventSubtypeMotionShake) {                //搖一搖 行為             }}- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event NS_AVAILABLE_IOS(3_0){} 

 4 圖片滑動換頁

 

UISwipeGestureRecognizer *recognizer;       self.img.userInteractionEnabled=YES;    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];    [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];    [[self img] addGestureRecognizer:recognizer];            }-(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {    NSLog(@"Swipe received.");        if (recognizer.direction==UISwipeGestureRecognizerDirectionRight) {        NSLog(@"swipe down");        [UIView beginAnimations:nil context:nil];        [UIView setAnimationDuration:2.0f];        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];        [UIView setAnimationRepeatAutoreverses:NO];        [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];        //界面變化部分       //........                [UIView commitAnimations];    }}

 


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 绥棱县| 原阳县| 仁化县| 临夏县| 阳城县| 大厂| 涪陵区| 集贤县| 贞丰县| 汤阴县| 花莲市| 六安市| 红原县| 泾源县| 车致| 台南县| 沅陵县| 马山县| 武城县| 湘乡市| 潍坊市| 桦川县| 尼木县| 吴川市| 军事| 缙云县| 鄂托克前旗| 古蔺县| 高邑县| 阜新市| 修武县| 泰安市| 邛崃市| 武邑县| 泉州市| 青浦区| 拉孜县| 唐河县| 日喀则市| 定结县| 紫云|