蘋果的軟件/系統盤 網站 http://www.panduoduo.net/u/bd-369186934/2


http://www.panduoduo.net/u/bd-369186934/2 

 

 

               UIViewController提供了一個基礎的視圖管理模型,可以用UIViewController管理視圖的繼承,及對view的管理。

               屬性:

               view:視圖  (UIViewController的一個屬性,用於UI控件的存放和操作)

               viewIfLoaded:是否加載視圖成功 (是一個只讀屬性,如果加載成功則返回視圖控制器的視圖,如果沒有加載成功則返回空值。iOS9加入)

               nibName:nib視圖的名字 (只讀)

               nibBundle:nib視圖的位置 (只讀)

               storyboard:故事版 (只讀)

               title:標題 (在父視圖控制器上面使用效果和self.navigationItem.title一樣)

               parentViewController:父視圖控制器 (只讀)

               modalViewController:模態視圖 (已經被presentedViewController取代,只讀)

               presentedViewController:被本視圖present出來的視圖控制器 (只讀)

               presentingViewController:present出本視圖控制器的視圖控制器   (只讀)

               definesPresentationContext:本視圖控制器的視圖是否被覆蓋時,視圖控制器或它的子類提供了一個視圖控制器。

               providesPresentationContextTransitionStyle:是否設定視圖在present使用不同的風格

               modalTransitionStyle:過渡風格 (取值為:UIModalTransitionStyle一共有4種情況:UIModalTransitionStyleCoverVertical:從下向上徐徐彈出,關閉時向下隱,UIModalTransitionStyleFlipHorizontal:水平旋轉的方式顯示,UIModalTransitionStyleCrossDissolve:漸變方式,UIModalTransitionStylePartialCurl:翻頁)

               modalPresentationStyle:彈出風格 (取值為:UIModalPresentationStyle一共有9種情況:UIModalPresentationFullScreen,UIModalPresentationPageSheet,UIModalPresentationFormSheet,UIModalPresentationCurrentContext,UIModalPresentationCustom,UIModalPresentationOverFullScreen,UIModalPresentationOverCurrentContext,UIModalPresentationPopover,UIModalPresentationNone

               modalPresentationCapturesStatusBarAppearance:設置狀態欄是否在屏幕滾動的時候隱藏,默認是NO(iOS7加入)

               wantsFullScreenLayout:iOS7已經被棄用

               edgesForExtendedLayout:指定邊緣延伸的方向 (取值為:UIRectEdge  一般在有nav的情況下使用時候延伸到nav下方iOS7加入)

               extendedLayoutIncludesOpaqueBars:屏幕滑動時下方的視圖是否穿過導航欄 (ios7 加入)

               automaticallyAdjustsScrollViewInsets:效果和extendedLayoutIncludesOpaqueBars類似

               preferredContentSize設置子視圖控制器的大小 (iOS7加入)

               interfaceOrientation:當前程序界面旋轉的方向 (取值為:UIInterfaceOrientation 有5種屏幕旋轉的情況)

               editing:是否允許編輯

               searchDisplayController:搜索框

               childViewControllers:子視圖控制器字典 (取值是NSArray

               restorationIdentifier:保存標題 恢復標識符 (取值是NSString

               restorationClass: 回復類

               topLayoutGuide:用於autolayout表示狀態欄底部的位置 (只讀 iOS7加入)

               bottomLayoutGuide:用於autolayout表示屏幕底部的位置 (只讀 iOS7加入)

               extensionContext:擴展上下文  (不懂,iOS8加入)

               presentationController:被present出來的視圖控制器 (只讀,iOS8加入)

               popoverPresentationController: 被pop出來的視圖控制器  (只讀,iOS8加入)

               previewingGestureRecognizerForFailureRelationship:預覽失敗手勢 (使用3Dtouch的時候配合使用,可以檢測到失敗的手勢。iOS9加入)

               sourceView:源視圖 (不懂,iOS9加入)

               sourceRect:源視圖范圍 (iOS9加入)

               方法:

              - (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil

            實例化某個視圖控制器

              - (nullable instancetype)initWithCoder:(NSCoder *)aDecoder;反歸檔

              - (void)loadView;加載視圖,生命周期只有一次

              - (void)loadViewIfNeeded;在視圖沒有加載成功的情況下將視圖創建出來,並重新調用viewDidLoad方法 (iOS9加入)

             - (void)viewWillUnload;視圖將會被卸載

             - (void)viewDidUnload;視圖被卸載

             - (void)viewDidLoad; 視圖加載完成 (一般在這個方法里面定義UI控件,制備調用一次)

             - (BOOL)isViewLoaded;判斷view是否被加載

             - (void)performSegueWithIdentifier:(NSString *)identifier sender:(nullable id)sender;用於storyboard中的界面跳轉

             - (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(nullable id)sender;是否能夠觸發segue跳轉方式

             - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(nullable id)sender;准備跳轉

             - (BOOL)canPerformUnwindSegueAction:(SEL)action fromViewController:(UIViewController *)fromViewController withSender:(id)sender;在UiViewController跳轉前調用,如果返回 NO則不跳轉

             - (NSArray<UIViewController *> *)allowedChildViewControllersForUnwindingFromSource:(UIStoryboardUnwindSegueSource *)source;允許釋放子視圖控制器並放回所有的視圖控制器(iOS9加入)

             - (nullable UIViewController *)childViewControllerContainingSegueSource:(UIStoryboardUnwindSegueSource *)source;子視圖控制器的segue源返回一個視圖控制器 iOS 9 加入)

            - (void)unwindForSegue:(UIStoryboardSegue *)unwindSegue towardsViewController:(UIViewController *)subsequentVC;自定義segue容器視圖控制器,用於跳轉 (iOS9加入)

            - (void)viewWillAppear:(BOOL)animated;視圖將要顯示

            - (void)viewDidAppear:(BOOL)animated;   視圖已經顯示

            - (void)viewWillDisappear:(BOOL)animated;視圖將要消失

            - (void)viewDidDisappear:(BOOL)animated;視圖已經消失

            - (void)viewWillLayoutSubviews;在viewWillAppare后調用,將要對子視圖進行布局

            - (void)viewDidLayoutSubviews;已經布局完成子視圖

            - (void)didReceiveMemoryWarning; 內存警告

            - (BOOL)isBeingPresented ; 是否允許開始跳轉
            - (BOOL)isBeingDismissed ;是否允許開始消失
            - (BOOL)isMovingToParentViewController ;是否移動到跳轉的視圖
            - (BOOL)isMovingFromParentViewController ;是否從跳轉的時候中返回

            - (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^ __nullable)(void))completion ;界面跳轉(展現)

            - (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^ __nullable)(void))completion 界面消失

            - (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated;展現模態視圖控制器

            - (void)dismissModalViewControllerAnimated:(BOOL)animated;退出模態視圖控制器

            - (BOOL)disablesAutomaticKeyboardDismissal;在UIModalPresentationFormSheet風格下是否允許鍵盤隱藏

            - (UIStatusBarStyle)preferredStatusBarStyle;狀態來顏色 (返回UIStatusBarStyleDefault在亮色的背景顏色下狀態欄顏色是暗色,返回UIStatusBarStyleLightContent在暗色的背景顏色下狀態欄顏色是亮色,iOS7加             入)

            - (BOOL)prefersStatusBarHidden;是否能夠隱藏狀態欄 (iOS7加入)

            - (UIStatusBarAnimation)preferredStatusBarUpdateAnimation;狀態欄顯示或者隱藏動畫 (iOS7加入)

            - (void)setNeedsStatusBarAppearanceUpdate;設置需要更新狀態欄 (iOS7加入)

            - (nullable UIViewController *)targetViewControllerForAction:(SEL)action sender:(nullable id)sender;返回一個最近的先祖視圖控制器,用於先祖視圖控制器和本視圖控制器之間的傳值。 (ios 8 加入)

            - (void)showViewController:(UIViewController *)vc sender:(nullable id)sender;顯示視圖並發送它的先祖 (iOS8加入)

            - (void)showDetailViewController:(UIViewController *)vc sender:(nullable id)sender;顯示視圖控制器中的細節 (iOS8加入)

            + (void)attemptRotationToDeviceOrientation;讓interface orientation和device orientation的方向立即保持一致。

            - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation;單獨控制某個UIVewController的旋轉方向

            - (BOOL)shouldAutorotate;是否自動轉屏

            - (UIInterfaceOrientationMask)supportedInterfaceOrientations;返回值決定interface orienation的旋轉方向

            - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation ;設置viewController在present時首選的默認方向

            - (nullable UIView *)rotatingHeaderView;查詢當前的導航視圖

            - (nullable UIView *)rotatingFooterView;查詢當前的標簽視圖

            - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;應用界面將要旋轉的時候前會調用

            - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;應用界面旋轉之后調用

            - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;在旋轉過程中制定旋轉結束后控件的位置大小

            - (void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;在旋轉過程中制定旋轉結束后控件的位置大小(發生在前半段)

            - (void)didAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation;在前半段旋轉之后發生,做一些自定義的操作
            - (void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)duration;在旋轉過程中制定旋轉結束后控件的位置大小(發生在后半段)

            - (void)setEditing:(BOOL)editing animated:(BOOL)animated; 重新設定editing或者done按鈕的外觀

            - (UIBarButtonItem *)editButtonItem;自定義的view,作為導航欄的edit或者done按鈕

            - (void)addChildViewController:(UIViewController *)childController ;添加子視圖控制器

            - (void) removeFromParentViewController;從父視圖控制器中刪除子視圖控制器

            - (void)transitionFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^ __nullable)(void))animations completion:(void (^ __nullable)(BOOL finished))completion;不同的view放到不同的視圖控制器中同時設置視圖控制器切換的時候的過度時間,過度效果,國度動畫

            - (void)beginAppearanceTransition:(BOOL)isAppearing animated:(BOOL)animated;視圖控制器開始出現轉變

            - (void)endAppearanceTransition;轉變結束同時觸發相應的viewWillDisappear方法

            - (nullable UIViewController *)childViewControllerForStatusBarStyle;子視圖控制器的狀態來風格 (iOS7加入)

            - (nullable UIViewController *)childViewControllerForStatusBarHidden;子視圖控制器狀態欄隱藏和取消隱藏狀態 (iOS7加入)

            - (void)setOverrideTraitCollection:(nullable UITraitCollection *)collection forChildViewController:(UIViewController *)childViewController;為子控制器重新設置traintCollection的值 (一般用於自定義              controller,ios8加入)

            - (nullable UITraitCollection *)overrideTraitCollectionForChildViewController:(UIViewController *)childViewController;獲取子控制器的trainCollection

            - (BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers;可以關閉appearance callbacks的自動傳遞特性(iOS5中)

            - (BOOL)shouldAutomaticallyForwardRotationMethods;禁止旋轉回調自動傳遞的特性(iOS6中)

            - (BOOL)shouldAutomaticallyForwardAppearanceMethods;在iOS6之后關閉appearance callbacks的自動傳遞特性

            - (void)willMoveToParentViewController:(nullable UIViewController *)parent;存在父視圖控制器和子視圖控制器的時候父視圖控制器將要出現的時候調用

            - (void)didMoveToParentViewController:(nullable UIViewController *)parent;在顯示ParentViewController之后自動調用

            - (void) encodeRestorableStateWithCoder:(NSCoder *)coder;保存視圖狀態相關信息(歸檔)

            - (void) decodeRestorableStateWithCoder:(NSCoder *)coder;恢復和保持視圖狀態相關信息

            - (void) applicationFinishedRestoringState;其他對象解碼完成后系統會自動調用此方法(iOS7加入)

            - (void)updateViewConstraints ;更新布局約束

            - (void)addKeyCommand:(UIKeyCommand *)keyCommand;添加按鍵命令 (iOS9加入)

            - (void)removeKeyCommand:(UIKeyCommand *)keyCommand;移除按鍵命令 (iOS9加入)

            - (nullable UIViewController *)previewingContext:(id <UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location;預覽上下文視圖控制器的和視圖控制器所在的位置 (iOS9加             入)?

            - (void)previewingContext:(id <UIViewControllerPreviewing>)previewingContext commitViewController:(UIViewController *)viewControllerToCommit ;添加視圖控制器並預覽 (iOS9加入)?

            - (id <UIViewControllerPreviewing>)registerForPreviewingWithDelegate:(id<UIViewControllerPreviewingDelegate>)delegate sourceView:(UIView *)sourceView

            - (void)unregisterForPreviewingWithContext:(id <UIViewControllerPreviewing>)previewing

            - (NSArray <id <UIPreviewActionItem>> *)previewActionItems;預覽操作項 (ios9加入)

            + (instancetype)actionWithTitle:(NSString *)title style:(UIPreviewActionStyle)style handler:(void (^)(UIPreviewAction *action, UIViewController *previewViewController))handler

            + (instancetype)actionGroupWithTitle:(NSString *)title style:(UIPreviewActionStyle)style actions:(NSArray<UIPreviewAction *> *)actions

          

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM