zoukankan      html  css  js  c++  java
  • VFL +AutoLayout

    横竖屏事件响应(viewWillLayoutSubviews和通知)两种方式

     http://blog.csdn.net/nogodoss/article/details/17246489

    一,NSLayoutConstraint API

    1,constraintsWithVisualFormat:

    + (NSArray *)constraintsWithVisualFormat:(NSString *)format options:(NSLayoutFormatOptions)opts metrics:(NSDictionary *)metrics views:(NSDictionary *)views;

    参数介绍:

    format:此参数为你的vfl语句,比如:@"H:|-[button]-|"  

        水平方向          H:        垂直方向          V:  

        Views         [view]    SuperView      |    

        关系         >=,==,<=

        空间,间隙       -

        优先级        @value

    opts:枚举参数,默认写0,具体跟据你所实现的需求去选择你想要的枚举

    metrics:这里是一个字典,当在format中使用了动态数据比如上现这句:@"H:|-[button(==width)]-|",表示这个button的宽度为width,那么这个参数去哪里找呢?就是在这个字典里面找到key对就的值,如果没有找到这个值,app就会crash.

    views:顾名思义,这是传所有你在vfl中使用到的view,那在上面这句例子中的应该怎么传呢?结果是这样的:NSDictionaryOfVariableBindings(button).如果你使用到了多个view,就可以这样NSDictionaryOfVariableBindings(button,button1,button3...),这个名字也要跟参数format中的一一对应,缺一不可.

    2, addConstraint:

    - (void)addConstraint:(NSLayoutConstraint *)constraint NS_AVAILABLE_IOS(6_0); // This method will be deprecated in a future release and should be avoided.  Instead, set NSLayoutConstraint's active property to YES.
    - (void)addConstraints:(NSArray *)constraints NS_AVAILABLE_IOS(6_0); // This method will be deprecated in a future release and should be avoided.  Instead use +[NSLayoutConstraint activateConstraints:].
    - (void)removeConstraint:(NSLayoutConstraint *)constraint NS_AVAILABLE_IOS(6_0); // This method will be deprecated in a future release and should be avoided.  Instead set NSLayoutConstraint's active property to NO.
    - (void)removeConstraints:(NSArray *)constraints NS_AVAILABLE_IOS(6_0); // This method will be deprecated in a future release and should be avoided.  Instead use +[NSLayoutConstraint deactivateConstraints:].
    

    eg:

    二,
    编码模式中,
    1.addConstraint(s)前,view应该去部被addSubView上去了。
    2.不必给views写frame
    3.给必要的view关掉AutoresizeingMask。[_aView setTranslatesAutoresizingMaskIntoConstraints:NO];
    4.UILabel换行要写linebreakMode,要写numberOfLines(iOS7.0默认好像是1,坑爹了)
    5.UILabel要想换行,一定要添加preferredMaxLayoutWidth。否则没法初始化宽度。

    3, 

    动态计算UITableViewCell高度详解

    http://www.ifun.cc/blog/2014/02/21/dong-tai-ji-suan-uitableviewcellgao-du-xiang-jie/#md-5 

     

  • 相关阅读:
    jQuery 淡入淡出
    (Windows窗体)循环动态绑定根节点及子节点
    C# 语音读取
    js禁用&启用某个按钮
    AWS DescribeDBInstances API 无法查询到 DBInstanceArn 参数
    Python 设置S3文件属性中元数据的Content-Encoding值
    Pyhton 批量重命名 AWS S3 中的文件
    Python 控制(SSM)AWS Systems Manager
    Python 根据AWS EC2设置的标签获取正在运行的instancesId
    python 'wb' 模式写入文件怎么输出回车
  • 原文地址:https://www.cnblogs.com/developer-qin/p/4766363.html
Copyright © 2011-2022 走看看