zoukankan      html  css  js  c++  java
  • ios 开发小记 (四)

    开发中的常见的问题:

    1、NSDictionary

    keyEnumerator 用来遍历dict

    但是在dict为空的时候调用会报错 

    使用前要注意。

    2、URL Scheme
    简单来叙述:
    URL Scheme就是一个应用的网址,当访问到应用对应的网址的时候,会打开应用。
    APP_A 打开 APP_B 的流程:
    1,APP_B 自定义URL scheme;
    2,安装并运行APP_B;(相当于注册)
    3,APP_A通过
     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]];
    打开APP_B;(可以传递参数) 
     
     
     
    3、Storyboard
    1. Storyboard中的First Responder只是一个placeholder,它不是具体指向哪个responder,
     
    2. 如果程序不在乎谁是First Responder,都让First Responder执行某个action(比如这里的paste:),那么我们就可以把event发给First Responder。 
     
     
     4、Autoresize
    autoresize的具体内容:
    typedef NS_OPTIONS(NSUInteger, UIViewAutoresizing) {
        UIViewAutoresizingNone                 = 0,
    UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
    UIViewAutoresizingFlexibleWidth = 1 << 1,
    UIViewAutoresizingFlexibleRightMargin = 1 << 2,
    UIViewAutoresizingFlexibleTopMargin = 1 << 3,
    UIViewAutoresizingFlexibleHeight = 1 << 4,
    UIViewAutoresizingFlexibleBottomMargin = 1 << 5
    };

    UIViewAutoresizingNone就是不自动调整。
    UIViewAutoresizingFlexibleLeftMargin 自动调整与superView左边的距离,保证与superView右边的距离不变。
    UIViewAutoresizingFlexibleRightMargin 自动调整与superView的右边距离,保证与superView左边的距离不变。
    UIViewAutoresizingFlexibleTopMargin 自动调整与superView顶部的距离,保证与superView底部的距离不变。
    UIViewAutoresizingFlexibleBottomMargin 自动调整与superView底部的距离,也就是说,与superView顶部的距离不变。
    UIViewAutoresizingFlexibleWidth 自动调整自己的宽度,保证与superView左边和右边的距离不变。
    UIViewAutoresizingFlexibleHeight 自动调整自己的高度,保证与superView顶部和底部的距离不变。
    UIViewAutoresizingFlexibleLeftMargin  |UIViewAutoresizingFlexibleRightMargin 自动调整与superView左边的距离,保证与左边的距离和右边的距离和原来距左边和右边的距离的比例不变。比如原来距离为20,30,调整后的距离应为68,102,即68/20=102/30。

    其它的组合类似。 

    默认情况下,View的autoresizing工作会根据当前位置自动设置约束。我们在使用代码写自己的约束布局代码时,必须设置当前View的translatesAutoresizingMaskIntoConstraints为NO,否则无法正常运作。IB默认是NO。
    这一点很重要!
     

     5、UIScrollView
    scrollView 里面的元素所用的约束是与contentSize 所约束
     如果需要定长宽 需要与外界的的交互
     
     
     
     6、UIGestureRecognizer
    UITapGestureRecognizer 与 view 一一对应
    当把tap 加到第二个view,第一个view失效。
     
    UIImageView  默认,是不让监听手势的,如果需要点击图片,记得在ib(attribute editor)中,打开。
     
     
    7、NSNotification
    Nsnotification 在发送的时候,要确保之前 监听的对象,仍有效
    为了防止给失效的object 发送消息。
     
     
    8、NSArray
    for in  arr 中,不要对arr操作。 会爆炸。
     
     
  • 相关阅读:
    [原创]SQL 把表中某一个列按照逗号拼接成一行
    [原创]SQL 把表中字段存储的逗号隔开内容转换成列表形式
    JQuery DataTables相关
    Jquery相关
    json字串主从表无法转成对像
    FastReport.net 使用 WebForm 实现打印 最简单版
    c# .netframwork 4.0 调用 2.0时报错 混合模式程序集是针对“v2.0.50727”版的运行时生成的,在没有配置其他信息的情况下,无法在 4.0 运行时中加载该程序集。
    FastReport.net 使用 Winform WebForm打印
    asp.net dev xtraReporting(一)静态页面
    C# DataTable转json 时间格式化
  • 原文地址:https://www.cnblogs.com/loying/p/4867814.html
Copyright © 2011-2022 走看看