zoukankan      html  css  js  c++  java
  • 来公司第一天

    1 ,translatesAutoresizingMaskIntoConstraints

    如果是从代码层面开始使用Autolayout,需要对使用的ViewtranslatesAutoresizingMaskIntoConstraints的属性设置为NO.
    即可开始通过代码添加Constraint,否则View还是会按照以往的autoresizingMask进行计算.
    而在Interface Builder中勾选了Ues Autolayout,IB生成的控件的translatesAutoresizingMaskIntoConstraints属性都会被默认设置NO.

    2,

    一般,Tap、pinch,pan、swipe只是一个简单的单个触摸,它有一定的局限性,所以多点触摸诞生了~为实现多点触摸,首先得做下列事情

    • 设置view的属性multipleTouchEnabled = YES(注意了。。。默认值是NO);
    • 使用CFDictionaryRef来保存触摸过程的参数 

    对于使用多点触摸处理事件,你必须频繁地存储以后进行触摸比较的触摸状态。例如,你要比较每个触摸的结束点位置和原始位置,你可以在touchesBegan:withEvent: 方法中获取每个触摸的原始位置(使用locationInView:方法),然后存储在CFDictionaryRef对象中,使用UITouch对象地址作为KEY。然后你可以在touchesEnded:withEvent: 方法中取出原始点,和当前点进行比较。

    需要注意的是这里使用CFDictionaryRef对象而不是NSDitionary对象,因为UITouch类没有实现NSCopying协议。

    代码
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [self cacheBeginPointForTouches:touches];
    }
    - (void)cacheBeginPointForTouches:(NSSet *)touches {
    if ([touches count] > 0) {
    for (UITouch *touch in touches) {
    CGPoint *point = (CGPoint *)CFDictionaryGetValue(touchBeginPoints,
    touch);
    } }
    if (point == NULL) {
    point = (CGPoint *)malloc(sizeof(CGPoint));
    CFDictionarySetValue(touchBeginPoints, touch, point);
    }
    *point = [touch locationInView:view.superview];
    }

  • 相关阅读:
    react的路由权限控制
    react的路由中的switch和exact的使用
    react中antd的表格自定义展开
    webstorm的git操作使用
    ES6的相关语法
    vue导出文件下载
    vue如何解析xml文件 x2js
    ES6模板字符串
    彻底卸载微软拼音输入法
    systemverilog新增的always_comb,always_ff,和always_latch语句
  • 原文地址:https://www.cnblogs.com/ygsios/p/4249896.html
Copyright © 2011-2022 走看看