美文网首页
iOS常用知识

iOS常用知识

作者: L小杰 | 来源:发表于2017-08-23 16:33 被阅读13次
  1. 解决成员变量block循环
__weak typeof(self) weakSelf = self;
 __strong typeof(weakSelf) strongSelf = weakSelf;

用strongSelf修饰的self 必须为 __weak 修饰过以后的self
strongSelf->解决成员变量,block循环引用

  1. 重写hittest
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
    for (UIView *subview in [self.subviews reverseObjectEnumerator]) {

        CGPoint convertedPoint = [subview convertPoint:point fromView:self];
        UIView *hitTestView = [subview hitTest:convertedPoint withEvent:event];
        if (hitTestView) {
            return hitTestView;
        }
    }
    return [super hitTest:point withEvent:event];
}
  1. 移除某个view的手势加在另一个上
//移除scrollViewA原有手势操作
NSMutableArray *list = [NSMutableArray arrayWithArray:scrollViewA.gestureRecognizers];
    for (UIGestureRecognizer *gestureRecognizer in list) {
        [scrollViewA removeGestureRecognizer:gestureRecognizer];
}

//将scrollViewB的手势操作加到scrollViewA中
for (UIGestureRecognizer *gestureRecognizer in scrollViewB.gestureRecognizers) {
        [scrollViewA addGestureRecognizer:gestureRecognizer];
}

相关文章

  • iOS 常用到的知识点(一)

    iOS 常用到的知识点(一)iOS 常用到的知识点(二)iOS 常用到的知识点(三) 1. CGRectGetM...

  • iOS 常用到的知识点(三)

    iOS 常用到的知识点(一)iOS 常用到的知识点(二)iOS 常用到的知识点(三) 1. navigationB...

  • iOS 常用到的知识点(二)

    iOS 常用到的知识点(一)iOS 常用到的知识点(二)iOS 常用到的知识点(三) 1.延迟加载: 2.布尔值存...

  • iOS 知识-常用小技巧大杂烩

    iOS 知识-常用小技巧大杂烩 - 简书

  • iOS常用知识

    1、禁止手机睡眠 [UIApplication sharedApplication].idleTimerDisab...

  • iOS常用知识

    解决成员变量block循环 用strongSelf修饰的self 必须为 __weak 修饰过以后的selfstr...

  • iOS常用知识

    网络TCP/IP 推荐《TCP/IP详解 卷一》HTTP协议结构,重用, 缓存,安全传输(HTTPS握+ 手机制)...

  • 积累~~~

    1. iOS - 10 各种权限 2. iOS - 知识库 3. 收集常用功能 4. iOS开发—判...

  • 一周技术回顾(2020.9.11)

    iOS 小知识 分享一个比较常用的知识点,点击某个UITableViewCell不执行-[UITableView ...

  • iOS 面试各要点 暂记

    ## iOS常用问题总结#### iOS基础知识回顾##### 1、为什么说Objective-C是一门动态的语言...

网友评论

      本文标题:iOS常用知识

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