1.UIModalTransitionStyle modal弹出动画风格
2.UIModalPresentationStyle modal弹出形式(frame方面)
@protocol UIContentContainer <NSObject>
3.@property (nonatomic, readonly) CGSize preferredContentSize
设置我们期望的childViewController的界面的大小
4.- (void)preferredContentSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container
通知当前VC,根据新的size调整UI
5.- (void)systemLayoutFittingSizeDidChangeForChildContentContainer:(id <UIContentContainer>)container
在这些情况下该方法会被调用,当前viewController没有使用auto layout布局,childrenViewController的view使用了autoLayout布局
6.- (CGSize)sizeForChildContentContainer:(id <UIContentContainer>)container withParentContainerSize:(CGSize)parentSize
当容器viewControllerViewWillTransitionTosize:withTransitionCoordinator:被调用时(我们重写这个方法时要调用super),sizeForChildContentContainer方法将被调用
7.- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
viewController的view的size被他的parent Controller改变时,会触发这个方法
8.- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id <UIViewControllerTransitionCoordinator>)coordinator
当viewController的traitCollection的值将要改变时会调用这个方法,这个方法是在UITraitEnvironment协议方法traitCollectionDidChange:之前被调用。
@end
9.UIKIT_EXTERN NSNotificationName const UIViewControllerShowDetailTargetDidChangeNotification
showViewController:sender and showDetailViewController:sender: 被调用时被触发
10.NS_CLASS_AVAILABLE_IOS(2_0) @interface UIViewController : UIResponder <NSCoding, UIAppearanceContainer, UITraitEnvironment, UIContentContainer>
UIViewController继承自UIResponder类,并实现NSCoding(实现归档操作),UIAppearanceContainer(允许开发者对UI控件通过定制都可以呈现各种外观),UITraitEnvironment(SizeClasses适配理念,通过内部的traitCollection属性,可以拿到对应的UITraitCollection对象,从而得知当前的SizeClass,进一步确定界面的布局),UIContentContainer协议(调整视图布局)
11.- (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil
加载对应nibName的viewController
12.- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder
NSCoding协议,通过IB创建时调用
13.@property(null_resettable, nonatomic,strong) UIView *view
14.- (void)loadView;
在loadView方法内部可以创建自定义的view
15.- (void)loadViewIfNeeded
iOS9之前
有些时候因为需要手动调用loadview
但是有风险,系统不再调用viewDidLoad
所以手动调用loadview是错误的
iOS9之后出现了loadViewIfNeeded解决了这个问题
调用这个方法视图会创建出来并且不会忽略viewDidLoad
16.@property(nullable, nonatomic, readonly, strong) UIView *viewIfLoaded
loaded返view、没load返nil
17.- (void)viewWillUnload
view将要销毁的时候会调用这个方法(不过现在已弃用)
18.- (void)viewDidUnload
view已经被销毁的时候会调用这个方法(现在也已弃用)
19.- (void)viewDidLoad
这个方法在view加载完毕的时候调用,执行顺序是在loadView方法调用之后调用
20.@property(nonatomic, readonly, getter=isViewLoaded) BOOL viewLoaded
判断view是否被加载完毕
21.
@property(nullable, nonatomic, readonly, copy) NSString *nibName; // The name of the nib to be loaded to instantiate the view.
@property(nullable, nonatomic, readonly, strong) NSBundle *nibBundle; // The bundle from which to load the nib.
@property(nullable, nonatomic, readonly, strong) UIStoryboard *storyboard NS_AVAILABLE_IOS(5_0);
22.SB相关
- (void)performSegueWithIdentifier:(NSString *)identifier sender:(nullable id)sender NS_AVAILABLE_IOS(5_0);
- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(nullable id)sender NS_AVAILABLE_IOS(6_0); // Invoked immediately prior to initiating a segue. Return NO to prevent the segue from firing. The default implementation returns YES. This method is not invoked when -performSegueWithIdentifier:sender: is used.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(nullable id)sender NS_AVAILABLE_IOS(5_0);
- (BOOL)canPerformUnwindSegueAction:(SEL)action fromViewController:(UIViewController *)fromViewController withSender:(id)sender NS_AVAILABLE_IOS(6_0);
- (NSArray<UIViewController *> *)allowedChildViewControllersForUnwindingFromSource:(UIStoryboardUnwindSegueSource *)source NS_AVAILABLE_IOS(9_0);
- (nullable UIViewController *)childViewControllerContainingSegueSource:(UIStoryboardUnwindSegueSource *)source NS_AVAILABLE_IOS(9_0);
- (nullable UIViewController *)viewControllerForUnwindSegueAction:(SEL)action fromViewController:(UIViewController *)fromViewController withSender:(nullable id)sender NS_DEPRECATED_IOS(6_0, 9_0);
- (void)unwindForSegue:(UIStoryboardSegue *)unwindSegue towardsViewController:(UIViewController *)subsequentVC NS_AVAILABLE_IOS(9_0);
- (nullable UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(nullable NSString *)identifier NS_DEPRECATED_IOS(6_0, 9_0);
23.
- (void)viewWillAppear:(BOOL)animated; // Called when the view is about to made visible. Default does nothing
- (void)viewDidAppear:(BOOL)animated; // Called when the view has been fully transitioned onto the screen. Default does nothing
- (void)viewWillDisappear:(BOOL)animated; // Called when the view is dismissed, covered or otherwise hidden. Default does nothing
- (void)viewDidDisappear:(BOOL)animated; // Called after the view was dismissed, covered or otherwise hidden. Default does nothing
24.- (void)viewWillLayoutSubviews 在重新布局子view前的时候会调用
- (void)viewDidLayoutSubviews 在重新布局子view后的时候会调用
25.
@property(nullable,nonatomic,weak,readonly) UIViewController *parentViewController;
@property(nullable, nonatomic,readonly) UIViewController *modalViewController
@property(nullable, nonatomic,readonly) UIViewController *presentedViewController NS_AVAILABLE_IOS(5_0);
@property(nullable, nonatomic,readonly) UIViewController *presentingViewController NS_AVAILABLE_IOS(5_0);
假设从A控制器通过present的方式跳转到了B控制器,那么 A.presentedViewController 就是B控制器;B.presentingViewController 就是A控制器。
26.@property(nonatomic,assign) BOOL definesPresentationContext
决定哪个父viewController的view应当呈现在当前,如果没有父viewController,呈现的将是根视图控制器。
27.@property(nonatomic,assign) BOOL providesPresentationContextTransitionStyle
如果这个属性是true的话,可以定义模态过渡转场的样式
28.@property (nonatomic) BOOL restoresFocusAfterTransition
自动设置上一次的焦点,默认为YES
29.
@property(nonatomic, readonly, getter=isBeingPresented) BOOL beingPresented NS_AVAILABLE_IOS(5_0);判断viewController是否正在展示
@property(nonatomic, readonly, getter=isBeingDismissed) BOOL beingDismissed NS_AVAILABLE_IOS(5_0);判断viewController是否正在消失
@property(nonatomic, readonly, getter=isMovingToParentViewController) BOOL movingToParentViewController NS_AVAILABLE_IOS(5_0);判断是否正在向父viewController移动
@property(nonatomic, readonly, getter=isMovingFromParentViewController) BOOL movingFromParentViewController判断是否正由父viewController移动而来
30.- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion
modal出VC,completion在viewDidAppear后回调
31.- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^)(void))completion
退出modal,completion可在viewDidDisappear后回调
32.旧modal,已弃用
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated NS_DEPRECATED_IOS(2_0, 6_0) __TVOS_PROHIBITED;
- (void)dismissModalViewControllerAnimated:(BOOL)animated NS_DEPRECATED_IOS(2_0, 6_0) __TVOS_PROHIBITED;
33.@property(nonatomic,assign) UIModalTransitionStyle modalTransitionStyle NS_AVAILABLE_IOS(3_0);
@property(nonatomic,assign) UIModalPresentationStyle modalPresentationStyle NS_AVAILABLE_IOS(3_2);
34.@property(nonatomic,assign) BOOL modalPresentationCapturesStatusBarAppearance
这个属性是控制是否显示状态栏
35.@property(nonatomic, readonly) BOOL disablesAutomaticKeyboardDismissal
关闭键盘相关
36.@property(nonatomic,assign) BOOL wantsFullScreenLayout
wantsFullScreenLayout=true,状态栏的高度就不会被算在视图里,也就是说有没有状态栏y坐标始终都是从0算起(不过此属性在iOS7已被弃用,下面属性替代此功能)
37.@property(nonatomic,assign) UIRectEdge edgesForExtendedLayout
iOS7的新属性,默认值为UIRectEdgeAll,在navigationController中view的默认布局从navigationBar开始,self.edgesForExtendedLayout=UIRectEdgeNone,则布局控件减去navigationBar
38.navi相关
@property(nonatomic,assign) BOOL extendedLayoutIncludesOpaqueBars NS_AVAILABLE_IOS(7_0); // Defaults to NO, but bars are translucent by default on 7_0.
@property(nonatomic,assign) BOOL automaticallyAdjustsScrollViewInsets API_DEPRECATED_WITH_REPLACEMENT("Use UIScrollView's contentInsetAdjustmentBehavior instead", ios(7.0,11.0),tvos(7.0,11.0)); // Defaults to YES
39.@property(nonatomic, readonly) UIStatusBarStyle preferredStatusBarStyle
statusBar黑白
40.@property(nonatomic, readonly) BOOL prefersStatusBarHidden
statusBar hidden
41.@property(nonatomic, readonly) UIStatusBarAnimation preferredStatusBarUpdateAnimation
statusBar动画样式
42.setNeedsStatusBarAppearanceUpdate
如果需要对状态栏进行刷新,调用此方法即可
43.- (nullable UIViewController *)targetViewControllerForAction:(SEL)action sender:(nullable id)sender
UIViewControllerRotation
44.+ (void)attemptRotationToDeviceOrientation
该方法的使用场景是interface orientation和device orientation不一致,但希望通过重新指定interface orientation的值,立即实现二者一致;如果这时只是更改了支持的interface orientation的值,没有调用attemptRotationToDeviceOrientation,那么下次device orientation变化的时候才会实现二者一致,关键点在于能不能立即实现。
45.- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
iOS6之前我们可以通过这个方法来单独控制某个UIVewController的旋转方向
46.
@property(nonatomic, readonly) BOOL shouldAutorotate NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
第一个方法决定是否支持多方向旋转屏,如果返回NO则后面的两个方法都不会再被调用,而且只会支持默认的UIInterfaceOrientationMaskPortrait方向
@property(nonatomic, readonly) UIInterfaceOrientationMask supportedInterfaceOrientations NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
第二个方法直接返回支持的旋转方向,该方法在iPad上的默认返回值是UIInterfaceOrientationMaskAll
,iPhone上的默认返回值是UIInterfaceOrientationMaskAllButUpsideDown
@property(nonatomic, readonly) UIInterfaceOrientation preferredInterfaceOrientationForPresentation NS_AVAILABLE_IOS(6_0) __TVOS_PROHIBITED;
第三个方法返回最优先显示的屏幕方向,比如同时支持Portrait和Landscape方向,但想优先显示Landscape方向,那软件启动的时候就会先显示Landscape,在手机切换旋转方向的时候仍然可以在Portrait和Landscape之间切换;
47.@property(nonatomic,getter=isEditing) BOOL editing;
- (void)setEditing:(BOOL)editing animated:(BOOL)animated;