IOS7 随记(一)之unwind segue

来源:互联网 发布:软件著作权打印要求 编辑:程序博客网 时间:2024/05/01 19:42

关于auto lay out,unwind segue,tiff,静态显示tableView内容,返回类型:instancetype and id

1.Auto Lay Out:

    a.选中控件,control-dray,分别从四个方向释放鼠标,会出现相对应方向的关于constraint的shortcut菜单

    b.或是从顶部菜单 Editor - Resolve Auto Layout Issues - Reset to Suggested Constraints

                 Editor - Resolve Auto layout Issues - Clear Constraints

2.unwind segue to navigate back:

    a-push/modal segue to-b,b-unwind segue to-a

    在a中定义(.h)- (IBAction)unwindToA:(UIStoryboardSegue *)unwindSegue;

            (.m)- (IBAction)unwindToA:(UIStoryboardSegue *)unwindSegue

               {

                   UIViewController* sourceViewController = unwindSegue.sourceViewController; //sourceViewController:b

                   if ([sourceViewController isKindOfClass:[B class]])

                   {

                       ......//事先可以sourceViewController(即b)中声明可公开访问的属性,以便在此可访问到

                   }

               }

     在main.storyboard中,将b中navigation bar上的按钮 control-drag到exit上(视图控制器界面上下方最右边绿色图标  ),在弹出的shortcut菜单上选中刚才设置的unwindToA,之后在运行时点击此按钮,即可返回

     p.s.在http://stackoverflow.com/questions/12561735/what-are-unwind-segues-for-and-how-to-use-them中有更详细描述

3。在mac中抓图:

     Launchpad-其他-抓图,完成后,文件是保存为tiff格式,双击此文件,在预览中把文件导出为png,就可当图像使用了

4.静态显示UITableView内容:

     a.TableView - Content:Static Cells

     b.Table View Cell - Style:Basic

     c.注释方法-numberOfSectionsInTableView:, tableView:numberOfRowsInSection:, tableView:cellForRowAtIndexPath:. 

5.返回类型:instancetype and id

    凡是通过alloc,init,new方式返回对象时,返回类型要用instancetype(而不是用id)

    e.g.

    @interface MyObject

    +(instancetype)myFactoryMethod;

    @end

    @implementation MyObject

    +(instancetype)myFactoryMethod {

        return [[[self class] alloc] init] ;  //要用self,这样才可以在其子类中也适用

    }

    @end


0 0