美文网首页
iOS开发细节记录

iOS开发细节记录

作者: c_xiaoqiang | 来源:发表于2015-10-23 11:31 被阅读93次

UITapGestureRecognizer单击和双击事件响应

如果tap事件定义在同一个地方的通用方法是下面:

UITapGestureRecognizer *singleTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doSingleTap)] autorelease];
singleTap.numberOfTapsRequired = 1; 
[self.view addGestureRecognizer:singleTap];
UITapGestureRecognizer *doubleTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doDoubleTap)] autorelease];
doubleTap.numberOfTapsRequired = 2; 
[self.view addGestureRecognizer:doubleTap];
[singleTap requireGestureRecognizerToFail:doubleTap];

但是如果子类的tap事件定义在别处,上面方法就比较麻烦了。就可以使用代理来解决这个问题.UIGestureRecognizerDelegate。这边假设doubleTap定义在子类,singleTap定义在父类,则由于代理的效果先响应doubleTap

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

//该方法返回YES,则就可以实现先响应别的方法
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}

UIViewController如何背景透明

通过设置modalPresentationStyle来实现,iOS8以前和iOS8以后方法不一样

if (IsGreaterIOS8) {
    _browser.modalPresentationStyle = UIModalPresentationOverCurrentContext;
}else{
    _browser.modalPresentationStyle = UIModalPresentationCurrentContext;
}

常用到的常量定义

#define ScreenWidth [UIScreen mainScreen].bounds.size.width
#define ScreenHeight [UIScreen mainScreen].bounds.size.height
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define IsGreaterIOS8 SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")

相关文章

  • iOS开发 UITableView 常用细节

    iOS开发 UITableView 常用细节 iOS开发 UITableView 常用细节

  • iOS开发细节记录

    UITapGestureRecognizer单击和双击事件响应 如果tap事件定义在同一个地方的通用方法是下面: ...

  • iOS开发小细节记录

    1. UILabel出现奇怪的边线 今天出现一个问题,UILabel莫名其妙的出现了黑色的边线。网上查了一下,是因...

  • 开发路上踏过的坑

    ——只灯片笺 此文记录的是笔者在实际iOS开发工作中遇到并解决的一些小细节问题,以此记录,持续更新,仅供参考。 G...

  • iOS开发细节

    解决有的图片显示时只是一块颜色,而显示不正常的问题 //渲染UIImage*image = [UIImageima...

  • iOS开发记录

    本文记录ios开发中的一些需要知道的细节,后期会持续更新,有需要请关注。 入口函数int main(int arg...

  • iOS 学习心得记录之:拿到了ViewController就等于

    iOS 开发心得记录之:拿到了ViewController就等于拿到了view 在学习开发 iOS 的时候,我有时...

  • iOS开发证书要点详解

    转自 iOS开发证书要点详解,ios证书详解 有细节修改。 首先,假设你使用过Apple设备(iMac/iPad/...

  • iOS开发小细节

    1.http 网络连接 1.在Info.plist中添加 App Transport Security Sett...

  • iOS开发常用细节

    前言 github:https://github.com/koknine (求star,follow ^_^) 之...

网友评论

      本文标题:iOS开发细节记录

      本文链接:https://www.haomeiwen.com/subject/jemthttx.html