惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
The Cloudflare Blog
博客园 - Franky
IT之家
IT之家
V
Visual Studio Blog
博客园 - 【当耐特】
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
爱范儿
爱范儿
Hugging Face - Blog
Hugging Face - Blog
宝玉的分享
宝玉的分享
博客园 - 叶小钗
有赞技术团队
有赞技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
罗磊的独立博客
小众软件
小众软件
Jina AI
Jina AI

博客园 - 狗尾草-大数据收割基

微信小程序-本地云函数调试失败,卡在“正在开启本地调试中” VS Code调试Python时,选择conda虚拟环境,配置环境变量 微信小程序集成vant mac配置ssh 到github (ios)MPMoviePlayerController首次播放视频的时候,没有控制条 ios app响应background,foreground 事件实现 ios UIScrollView 中控件自动增加间隔 iOS 导航栏实现总结 ios界面布局整理 android ProGuard 代码混淆实现 mac版 android破解软件下载安装 在unix系统下的 .o文件 .a文件 .so文件说明和相互关系 android中的广播接收实现总结 用java的jdk 生成android 的jni接口文档 Android 自定义Application android项目中配置NDK自动编译生成so文件 创建android Notification (ios) nsnotification总结 sqlite数据库 select 查询带换行符数据
(ios) 屏幕触摸总结
狗尾草-大数据收割基 · 2014-01-15 · via 博客园 - 狗尾草-大数据收割基

1  屏幕触控实现(单击 双击)

  [self becomeFirstResponder];
     //允许多点互动
     self.view.multipleTouchEnabled=TRUE;

实现事件部分

#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
{
  //结束
 UITouch *atouch=[touches anyObject];
    if(atouch.tapCount>=2)
    {
        //双击
    }
    else if(atouch.tapCount==1)
    {
    
       //单击
    }
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{


}

2 手势识别(UIlabel 点击事件实现)

  //设置图片的点击事件
    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 屏幕晃动实现

//AppDelegate 中实现
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    application.applicationSupportsShakeToEdit = YES;
}

//或者代码中实现
 [[UIApplication sharedApplication] setApplicationSupportsShakeToEdit:YES];

//ViewController 中实现下面方法

- (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];
    }
}