从storyboard与xib中加载与手动代码创建调用方法顺序

来源:互联网 发布:淘宝如何删除评论 编辑:程序博客网 时间:2024/06/06 14:00

    XBbtn *btn = [[XBbtnalloc] init];

    btn.frame =CGRectMake(100 ,100, 60, 60);

    [btn setTitle:@"btn1"forState:UIControlStateNormal];

    btn.backgroundColor = [UIColorredColor];

    [self.viewaddSubview:btn];

   /*

     1. storyboardxib中加载uiview控件调用方法顺序:

    2015-08-19 09:32:33.494 NSOperationqueue的基本使用[2495:82481] +[XBbtn allocWithZone:] --1

    2015-08-19 09:32:33.495 NSOperationqueue的基本使用[2495:82481] -[XBbtn initWithCoder:] --2

    2015-08-19 09:32:33.500 NSOperationqueue的基本使用[2495:82481] -[XBbtn awakeFromNib]   --3

    2015-08-19 09:32:33.520 NSOperationqueue的基本使用[2495:82481] -[XBbtn layoutSubviews] --4

    2015-08-19 09:32:33.520 NSOperationqueue的基本使用[2495:82481] -[XBbtn layoutSubviews] --5

     */

   /*

     2. 通过代码创建调用方法顺序:

     2015-08-19 09:35:10.735 NSOperationqueue的基本使用[2533:83738] +[XBbtn allocWithZone:]--1

     2015-08-19 09:35:13.734 NSOperationqueue的基本使用[2533:83738] -[XBbtn init]          --2

     // 注意:init 方法内部会调用 initWithFrame方法

     2015-08-19 09:35:14.503 NSOperationqueue的基本使用[2533:83738] -[XBbtn initWithFrame:]--3

     // [self.view addSubview:btn]添加到父view中的时候这个方法才会被调用

     2015-08-19 09:42:31.768 NSOperationqueue的基本使用[2827:89698] -[XBbtn layoutSubviews]--4

     2015-08-19 09:42:31.774 NSOperationqueue的基本使用[2827:89698] -[XBbtn layoutSubviews]--5

     */



0 0
原创粉丝点击