您的位置:首页 > 运维架构

第十七章 Autorotation, Popover Controllers, and Modal View Controllers翻译

2016-05-18 15:34 363 查看
一,你可以为应用定制每个方向的布局

二,Autorotation

       1,有device orientation和 interface orientation2种,取它们的插值得到可以支持的旋转方向

       2,device orientaion代表设备的当前旋转方向,可以通过UIDevice的orientation进行获取

       3,interface orientation代表页面的当前旋转方向,可以重载supportedInterfaceOrientations方法,它只能设置rootviewcontroller和present viewcontroller的方向,

             无法直接设置其他的viewcontroller

三,Rotation Notification

       1,在旋转方向改变的时候,应用会收到通知

              willAnimateRotationToInterfaceOrientation:duration:.; 你可以在这个方法中定制view布局

       2,可以通过interfaceOrientation.获取当前viewController的方向

       3,Android的广播主要是用于进程间通信,它主要是基于观察者模式,发送的广播同样会作为一种事件加入到消息循环中;

            在ios中引用处理旋转时,当收到系统发送的事件后,在程序内部进程中以广播的方式发送广播(为什么要发送广播,因为可能有多个组件监听这个事件)   

  

四,UIPopoverController显示浮动框

       1,可以移动的窗口?

       2,只在IPad设备上支持

       3,在popover中添加controller

self.imagePickerPopover = [[UIPopoverController alloc]
initWithContentViewController:imagePicker];


     4,popover消失处理

          它的delegate会收到popoverControllerDidDismissPopover:消息;

五,More Modal View Controllers

        1,可以以modally的方式显示一个view controller

        2,显示:presentViewController

        3,消失:dismissViewControllerAnimated

        4,可以使用presentingViewController获取对应的present它的view controller

        5,一般用于2个不相关的控制器之间的切换

        

六,block  函数指针

         某些情况下,需要在某些方法中添加额外的回调:

         

- (void)dismissViewControllerAnimated:(BOOL)flag
completion:(void (^)(void))completion;
     

       此时可以创建一个block对象,即相当于c中的函数指针

        1,可以使用快捷方式创建  ^ { }

              

^{
[self.tableView reloadData];
};


六,线程安全单实例模式

static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedStore = [[self alloc] initPrivate];
});

七,view controller之间的关系

        1,可以用于页面之间的跳转,所以非常重要

        2,container - child之间的关系

              container维护一个堆栈,viewcontrollers;

              child可以通过parentviewcontroller获取上一级的view controller;

        3,presented presenting之间的关系

              可以通过presentedViewController获取present的view controller;

               可以通过presentingViewController获取是谁present;        

        4,presentingViewController的值都是最顶部的view controller和哪一个发布的没关系

        5,view controller family之间无法使用tabBarController、navigationController等property访问             

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: