IOS8 UIViewcontroller API使用说明
2014-12-25 10:20
369 查看
1、UIViewControllerIn iOS 8, all rotation-related methods are deprecated. Instead, rotations are treated as a change in the size of the view controller’s view and are
therefore reported using the
When the interface orientation changes, UIKit calls this method on the window’s root view controller. That view controller then notifies its child view controllers, propagating the message throughout the view controller hierarchy.在iOS中8,所有与旋转相关的方法已过时或被弃用。取而代之,旋转将被视为在视图控制器的视图的大小的变化,并因此报告使用viewWillTransitionToSize:withTransitionCoordinator:方法。当界面的方向发生变化,UIKit会调用窗口的根视图控制器上此方法。该视图控制器然后通知其子视图控制器,在整个视图控制器层次传播消息。In iOS 6 and iOS 7, your app supports
the interface orientations defined in your app’s
A view controller can override the
to limit the list of supported orientations. Typically, the system calls this method only on the root view controller of the window or a view controller presented to fill the entire screen; child view controllers use the portion of the window provided for
them by their parent view controller and no longer participate directly in decisions about what rotations are supported. The intersection of the app'€™s orientation mask and the view controller'€™s orientation mask is used to determine which orientations a
view controller can be rotated into.在iOS6和iOS7系统,您的应用程序支持通过Info.plist文件来定义界面可旋转的方向。视图控制器也可以通过实现supportedInterfaceOrientations方法来限制支持方向的列表。典型地,调用此方法只对该本类控制器有效;对子类或者其他控制器无效。When
a rotation occurs for a visible view controller, the
and
are called during the rotation. The
is also called after the view is resized and positioned by its parent. If a view controller is not visible when an orientation change occurs, then the rotation methods are never called. However, the
is called when the view becomes visible. Your implementation of this method can call the
to determine the device orientation.当旋转事件发生在一个可见的视图控制器上面时,该willRotateToInterfaceOrientation:duration:,willAnimateRotationToInterfaceOrientation:duration:和didRotateFromInterfaceOrientation:方法是在旋转过程中被调用。该viewWillLayoutSubviews方法在视图的大小和位置由其父之后也被调用。如果一个视图控制器是不可见的,当一个方向发生变化,那么旋转方法不会被调用。但是,当视点变得可见时viewWillLayoutSubviews方法会被调用。实现viewWillLayoutSubviews方法可以调用statusBarOrientation方法来确定设备方向。推出另一个视图控制器样式typedefenum{UIModalPresentationFullScreen=0,UIModalPresentationPageSheet,UIModalPresentationFormSheet,UIModalPresentationCurrentContext,UIModalPresentationCustom,UIModalPresentationOverFullScreen,UIModalPresentationOverCurrentContext,UIModalPresentationPopover,UIModalPresentationNone=-1}UIModalPresentationStyle;过渡模式样式typedefenum{UIModalTransitionStyleCoverVertical=0,UIModalTransitionStyleFlipHorizontal,UIModalTransitionStyleCrossDissolve,UIModalTransitionStylePartialCurl,}UIModalTransitionStyle;-
(void)updateViewConstraints
修改视图约束条件You
may override this method in a subclass in order to add constraints to the view or its subviews. If you override this method, your implementation must invoke super’s implementation.@property(nonatomic, assign) BOOLautomaticallyAdjustsScrollViewInsets
滑动视图自动修正inset偏移量Default value is
View controllers set as the root view controller do not react to this property. Default value is
following:
*)
*)separateSecondaryViewControllerForSplitViewController:(UISplitViewController *)
it may need to know when a split view controller higher in the view hierarchy has changed.
sent when a split view controller expands or collapses. The object of this notification is the view controller that caused the change.Available in iOS 8.0 and later.
therefore reported using the
viewWillTransitionToSize:withTransitionCoordinator:method.
When the interface orientation changes, UIKit calls this method on the window’s root view controller. That view controller then notifies its child view controllers, propagating the message throughout the view controller hierarchy.在iOS中8,所有与旋转相关的方法已过时或被弃用。取而代之,旋转将被视为在视图控制器的视图的大小的变化,并因此报告使用viewWillTransitionToSize:withTransitionCoordinator:方法。当界面的方向发生变化,UIKit会调用窗口的根视图控制器上此方法。该视图控制器然后通知其子视图控制器,在整个视图控制器层次传播消息。In iOS 6 and iOS 7, your app supports
the interface orientations defined in your app’s
Info.plistfile.
A view controller can override the
supportedInterfaceOrientationsmethod
to limit the list of supported orientations. Typically, the system calls this method only on the root view controller of the window or a view controller presented to fill the entire screen; child view controllers use the portion of the window provided for
them by their parent view controller and no longer participate directly in decisions about what rotations are supported. The intersection of the app'€™s orientation mask and the view controller'€™s orientation mask is used to determine which orientations a
view controller can be rotated into.在iOS6和iOS7系统,您的应用程序支持通过Info.plist文件来定义界面可旋转的方向。视图控制器也可以通过实现supportedInterfaceOrientations方法来限制支持方向的列表。典型地,调用此方法只对该本类控制器有效;对子类或者其他控制器无效。When
a rotation occurs for a visible view controller, the
willRotateToInterfaceOrientation:duration:,
willAnimateRotationToInterfaceOrientation:duration:,
and
didRotateFromInterfaceOrientation:methods
are called during the rotation. The
viewWillLayoutSubviewsmethod
is also called after the view is resized and positioned by its parent. If a view controller is not visible when an orientation change occurs, then the rotation methods are never called. However, the
viewWillLayoutSubviewsmethod
is called when the view becomes visible. Your implementation of this method can call the
statusBarOrientationmethod
to determine the device orientation.当旋转事件发生在一个可见的视图控制器上面时,该willRotateToInterfaceOrientation:duration:,willAnimateRotationToInterfaceOrientation:duration:和didRotateFromInterfaceOrientation:方法是在旋转过程中被调用。该viewWillLayoutSubviews方法在视图的大小和位置由其父之后也被调用。如果一个视图控制器是不可见的,当一个方向发生变化,那么旋转方法不会被调用。但是,当视点变得可见时viewWillLayoutSubviews方法会被调用。实现viewWillLayoutSubviews方法可以调用statusBarOrientation方法来确定设备方向。推出另一个视图控制器样式typedefenum{UIModalPresentationFullScreen=0,UIModalPresentationPageSheet,UIModalPresentationFormSheet,UIModalPresentationCurrentContext,UIModalPresentationCustom,UIModalPresentationOverFullScreen,UIModalPresentationOverCurrentContext,UIModalPresentationPopover,UIModalPresentationNone=-1}UIModalPresentationStyle;过渡模式样式typedefenum{UIModalTransitionStyleCoverVertical=0,UIModalTransitionStyleFlipHorizontal,UIModalTransitionStyleCrossDissolve,UIModalTransitionStylePartialCurl,}UIModalTransitionStyle;-
(void)updateViewConstraints
修改视图约束条件You
may override this method in a subclass in order to add constraints to the view or its subviews. If you override this method, your implementation must invoke super’s implementation.@property(nonatomic, assign) BOOLautomaticallyAdjustsScrollViewInsets
滑动视图自动修正inset偏移量Default value is
YES
@property(nonatomic) CGSize preferredContentSize
优先设置内容大小
The value in this property is used primarily when displaying the view controller’s content in a popover but may also be used in other situations. Changing the value of this property while the view controller is being displayed in a popover animates the size change; however, the change is not animated if you specify a width or height of0.0.
@property(nonatomic, assign) UIRectEdge
edgesForExtendedLayout
This property is only applied to view controllers that are embedded in containers, such as.UINavigationControlleror [code]UITabBarController
View controllers set as the root view controller do not react to this property. Default value is
UIRectEdgeAll.[/code]
@property(nonatomic, readonly, retain) id< UILayoutSupport >bottomLayoutGuide
As
an example of how to programmatically use this property with Auto Layout, say you want to position a control such that its bottom edge is 20 points above the bottom layout guide. This scenario applies to any of the scenarios listed above. Use code similar
to the following:
约束示例:
[buttonsetTranslatesAutoresizingMaskIntoConstraints:
NO];
idbottomGuide
=
myViewController.bottomLayoutGuide;
NSDictionary*viewsDictionary=
NSDictionaryOfVariableBindings
(button,bottomGuide);
[myViewController.viewaddConstraints:
[NSLayoutConstraintconstraintsWithVisualFormat:
@"V: [button]-20-[bottomGuide]"
options:0
metrics:nil
views:viewsDictionary]];
[self.viewlayoutSubviews];// You must call this method here or the system raises an exception获取高度
-(void)viewDidLayoutSubviews
{
CGRectviewBounds
=
self.view.bounds;
CGFloatbottomBarOffset
=
self.bottomLayoutGuide.length;
}In the case of using a view subclass, obtain the numbers you need as follows:
-(void)layoutSubviews
{
[superlayoutSubviews];// You must call super here or the system raises an exception
CGRectbounds
=
self.bounds;
CGFloatbottomBarOffset
=
myVCReference.bottomLayoutGuide.length;
}@property(nonatomic, readonly, retain) id< UILayoutSupport >topLayoutGuideAs an example of how to programmatically use this property with Auto Layout, say you want to position a control such that its top edge is 20 points below the top layout guide. This scenario applies to any of the scenarios listed above. Use code similar to the
following:
[buttonsetTranslatesAutoresizingMaskIntoConstraints:
NO];
idtopGuide
=
myViewController.topLayoutGuide;
NSDictionary*viewsDictionary=
NSDictionaryOfVariableBindings
(button,topGuide);
[myViewController.viewaddConstraints:
[NSLayoutConstraintconstraintsWithVisualFormat:
@"V: [topGuide]-20-[button]"
options:0
metrics:nil
views:viewsDictionary]];
[self.viewlayoutSubviews];// You must call this method here or the system raises an exception- (void)collapseSecondaryViewController:(UIViewController
*)
secondaryViewControllerforSplitViewController:(UISplitViewController *)
splitViewController
This method provides default behavior when you do not overwrite thesplitViewController:collapseSecondaryViewController:ontoPrimaryViewController:method.
The primary view controller associated with the split view controller is displayed.
Available in iOS 8.0 and later.- (UIViewController
*)separateSecondaryViewControllerForSplitViewController:(UISplitViewController *)
splitViewController
This method provides default behavior when you do not overwrite thesplitViewController:separateSecondaryViewControllerFromPrimaryViewController:method.
The previous secondary view controller is returned.
Available in iOS 8.0 and later.
@property(nonatomic, readonly, retain) NSExtensionContext*extensionContext
The view controller can check this property to see if it participates in an extension request. If no extension context is set for the current view controller, the system walks up the view controller hierarchy to find a parent view controller that has a nonvalue.[/code]nil[code]extensionContext
Available in iOS 8.0 and later.
NSString
*const
UIViewControllerShowDetailTargetDidChangeNotification
UIViewControllerShowDetailTargetDidChangeNotificationThis notification is sent when a split view controller is expanded or collapsed.When a view controller is using
showViewController:sender:or
showDetailViewController:sender:,
it may need to know when a split view controller higher in the view hierarchy has changed.
UIViewControllerShowDetailTargetDidChangeNotificationis
sent when a split view controller expands or collapses. The object of this notification is the view controller that caused the change.Available in iOS 8.0 and later.
相关文章推荐
- ios8 UIApplication API使用说明
- 如何获取错误消息说明使用 FormatMessage API
- 关于OSCache的JavaApi的使用说明
- Android3.1和3.2及google_api下载使用说明
- Mootools 1.4 官方网站的API使用说明存在错误
- 缺陷跟踪系统BugTracker.NET 汉化版(扩展Metaweblog API) 使用说明
- 使用PB调用API自动更新(非FTP模式)(二、API说明及定义(1))
- Google字体API使用说明
- jQuery UI 插件 使用说明+官方插件js包+jQuery及UI官方英文原版API手册
- jQuery验证控件jquery.validate.js使用说明+中文API
- TPTP Agent Controller使用说明
- C#中使用API(SHFileOperation)进行文件操作,特别说明了回收站相关参数
- 关于Google Map API的使用说明
- Apidemo 中关于如何使用ScrollView说明
- Libscws C API 使用说明
- InternetOpen/InternetOpenUrl/InternetReadFile 等相关Win32 网络API 使用详细说明
- DWR高级主题之DWR与spring集成(使用SpringMVC时dwr:controller标签说明)
- 如何获取错误消息说明使用 FormatMessage API
- jQuery UI 插件 使用说明+官方插件js包+jQuery及UI官方英文原版API手册
- jQuery验证控件jquery.validate.js使用说明+中文API