zoukankan      html  css  js  c++  java
  • iOS中常用的手势

    --前言

    智能手机问世后的很长一段时间,各大手机厂商都在思考着智能手机应该怎么玩?也都在尝试着制定自己的一套操作方式。直到2007年乔布斯发布了iPhone手机,人们才认识到智能手机就应该这样玩。

    真正让广大生产厂商惊掉下巴的是2010年6月8号发布的iPhone4。之前的iPhone基本都是极客玩物,很多大厂如NOKIA,摩托罗拉并没有把它看作一个够体量的对手。

    下图是2009年11月的国美手机销售排行榜:

    2010年6月的手机杂志的封面iPhone就已经占据上风了。可以看出当时的NOKIA E72还是很火,很多中高端手机还没有加入触控功能:

    iPhone在操作上的创举,很大程度上取决于用户在iPhone屏幕上实用的操作手势。

    --正文

    iOS上常用的手势有以下七种:

    1、点击手势(单击、双击)

    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(processgestureReconizer:)];  
    singleTap.numberOfTapsRequired = 1;    
    [self.view addGestureRecognizer:singleTap];

    2、拖拽手势

    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(processgestureReconizer:)];    
    [self.view addGestureRecognizer:pan];

    3、捏合手势(缩放)

    UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(processgestureReconizer:)];    
    [self.view addGestureRecognizer:pinch];

    4、旋转手势

    UIRotationGestureRecognizer *rotation = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(processgestureReconizer:)];    
    [self.view addGestureRecognizer:rotation];

    5、轻扫手势(从左到右、从右到左、从上到下、从下到上)

    UISwipeGestureRecognizer *leftSwipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(processgestureReconizer:)];    
    leftSwipe.direction = UISwipeGestureRecognizerDirectionLeft;    
    [self.view addGestureRecognizer:leftSwipe];

    6、长按手势

    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(processgestureReconizer:)];    
    longPress.minimumPressDuration = 2.0;    
    [self.view addGestureRecognizer:longPress];

    7、边缘滑动手势(左滑退出)

    UIScreenEdgePanGestureRecognizer edgePan = [[UIScreenEdgePanGestureRecognizer alloc]initWithTarget:self action:@selector(edgePanAction:)];
    edgePan.edges = UIRectEdgeLeft;
    [self.view addGestureRecognizer:edgePan];

    --另外

    手势是可以自定义的,上面列举的手势类都是UIGestureRecognizer类的子类。通过子类化UIGestureRecognizer可以制定出各种手势,比如iPhone设置中的自定义手势(用手指画一个‘勾’以后触发某种活动)。

    如果UIGestureRecognizer类都让你束手束脚,高手的你也可以直接使用像UITouch这样的类,来高度自定义各种“手法”。

  • 相关阅读:
    Javascript FP-ramdajs
    微信小程序开发
    SPA for HTML5
    One Liners to Impress Your Friends
    Sass (Syntactically Awesome StyleSheets)
    iOS App Icon Template 5.0
    React Native Life Cycle and Communication
    Meteor framework
    RESTful Mongodb
    Server-sent Events
  • 原文地址:https://www.cnblogs.com/cchHers/p/10132099.html
Copyright © 2011-2022 走看看