UIViewController API

/*

UIViewController is a generic controller base class that manages a view.? It has methods that are called

when a view appears or disappears.

Subclasses can override -loadView to create their custom view hierarchy, or specify a nib name to be loaded

automatically.? This class is also a good place for delegate & datasource methods, and other controller

stuff.

*/

@classUIView;

//1. UIViewController是管理一個(gè)view的最基本的基類,當(dāng)一個(gè)view要顯示或者消失的時(shí)候徒爹,UIViewController有相應(yīng)方法會(huì)被調(diào)用。子類可以重寫loadView方法去創(chuàng)建他們自定義的view澜搅,或者指定一個(gè)nib被自動(dòng)加載實(shí)現(xiàn)刊侯。這個(gè)類也是對(duì)于代理讳苦,數(shù)據(jù)源協(xié)議方法和一些其他控制器的方法展示實(shí)現(xiàn)一個(gè)很好的空間地方。

@classUINavigationItem, UIBarButtonItem, UITabBarItem;

//2. UINavigationItem是放置在導(dǎo)航欄中的,包含.rightBarButtonItem批狐,.leftBarButtonItem扇售,titleView前塔,而這三個(gè)按鈕又可以歸為UIBarButtonItem類,并通過(guò)它創(chuàng)建承冰。UITabBarItem是分欄控制器底部切換item按鈕华弓。

@classUISearchDisplayController

//3. UISearchDisplayController是專門為UITableView搜索封裝的一個(gè)類。

@classUIPopoverController;

//4.UIPopverController是IPad特有的類困乒,不能在iphone上使用寂屏,它負(fù)責(zé)控制Popover視圖。Popover是一種臨時(shí)視圖娜搂,它以“漂浮”的形式出現(xiàn)在視圖里面迁霎。

@classUIStoryboard, UIStoryboardSegue;

//5. UIStoryboard是iOS5以后新增的內(nèi)容,是以故事版的形式來(lái)展示界面之間的邏輯業(yè)務(wù)關(guān)系百宇,前端開發(fā)目前有三種方式(純代碼考廉,代碼+xib,UIStoryboard)恳谎,UIStoryboard為其中一種芝此。而UIStoryboardSegue—————————————————————

@classUIScrollView

//6. UIScrollView在UIKit中是UIScrollView類憋肖,是容器類型的視圖因痛。它有三個(gè)子類—UITextView,UITableview和UICollectionView岸更,它們?cè)趦?nèi)容超出屏幕時(shí)提供水平或垂直滾動(dòng)條鸵膏。

@protocolUIViewControllerTransitionCoordinator;

//7.這就涉及到自定義viewController容器轉(zhuǎn)場(chǎng),iOS7引入的新特性自定義viewController轉(zhuǎn)場(chǎng)怎炊。-----------

typedefNS_ENUM(NSInteger, UIModalTransitionStyle) {

UIModalTransitionStyleCoverVertical =0,

UIModalTransitionStyleFlipHorizontal,

UIModalTransitionStyleCrossDissolve,

UIModalTransitionStylePartialCurlNS_ENUM_AVAILABLE_IOS(3_2),

};

//8.UIModalTransitionStyle是彈出模態(tài)ViewController時(shí)的四種動(dòng)畫風(fēng)格谭企,UIModalTransitionStyleCoverVertical是從底部滑入,UIModalTransitionStyleFlipHorizontal是水平翻轉(zhuǎn)评肆,UIModalTransitionStyleCrossDissolve是交叉溶解债查,UIModalTransitionStylePartialCurl是翻頁(yè)效果。

typedefNS_ENUM(NSInteger, UIModalPresentationStyle) {

UIModalPresentationFullScreen =0,

UIModalPresentationPageSheetNS_ENUM_AVAILABLE_IOS(3_2),

UIModalPresentationFormSheetNS_ENUM_AVAILABLE_IOS(3_2),

UIModalPresentationCurrentContextNS_ENUM_AVAILABLE_IOS(3_2),

UIModalPresentationCustomNS_ENUM_AVAILABLE_IOS(7_0),

UIModalPresentationOverFullScreenNS_ENUM_AVAILABLE_IOS(8_0),

UIModalPresentationOverCurrentContextNS_ENUM_AVAILABLE_IOS(8_0),

UIModalPresentationPopoverNS_ENUM_AVAILABLE_IOS(8_0),

UIModalPresentationNoneNS_ENUM_AVAILABLE_IOS(7_0) = -1,

};

//9瓜挽,UIModalPresentationStyle是彈出模態(tài)ViewController時(shí)彈出風(fēng)格盹廷,UIModalPresentationFullScreen是彈出VC時(shí),VC充滿全屏久橙,UIModalPresentationPageSheet是如果設(shè)備橫屏俄占,VC的顯示方式則從橫屏下方開始,UIModalPresentationFormSheet是VC顯示都是從底部淆衷,寬度和屏幕寬度一樣缸榄。UIModalPresentationCurrentContext是VC的彈出方式和VC父VC的彈出方式相同。.....UIModalPresentationNone測(cè)試時(shí)會(huì)崩潰祝拯,出錯(cuò)'The specified modal presentation style doesn't have a corresponding presentation controller.'-------------------------------

@protocolUIContentContainer

//10.iOS8之后甚带,加入了新的一組協(xié)議,UIViewController對(duì)這組協(xié)議提供了默認(rèn)的實(shí)現(xiàn),我們自定義ViewConttroller的時(shí)候可以重寫這些方法來(lái)調(diào)整視圖布局欲低。

@property(nonatomic, readonly) CGSize preferredContentSizeNS_AVAILABLE_IOS(8_0);

//11.我們可以使用preferredContentSize來(lái)設(shè)置我們期望的childViewController的界面的大小辕宏。

- (void)preferredContentSizeDidChangeForChildContentContainer:(id)containerNS_AVAILABLE_IOS(8_0);

//12.這個(gè)方法告訴當(dāng)前容器viewController,我們可以在這個(gè)方法里根據(jù)新的size對(duì)界面進(jìn)行調(diào)整砾莱。

/*

Intended as a bridge for a view controller that does not use auto layout presenting a child that does use auto layout.

If the child's view is using auto layout and the -systemLayoutSizeFittingSize: of the view

changes, -systemLayoutFittingSizeDidChangeForChildContentContainer: will be sent to the view controller's parent.

*/

- (void)systemLayoutFittingSizeDidChangeForChildContentContainer:(id)containerNS_AVAILABLE_IOS(8_0);

//13.重寫方法來(lái)調(diào)整視圖布局瑞筐,當(dāng)在這些情況下該方法會(huì)被調(diào)用,當(dāng)前viewController沒有使用auto layout布局腊瑟,childrenViewController的view使用了autoLayout布局childrenViewController View-systemLayoutSizeFittingSize:方法返回的值的改變(view由于內(nèi)容的改變聚假,size也出現(xiàn)了變化)

/*

When the content container forwards

viewWillTransitionToSize:withTransitionCoordinator: to its children, it

will call this method to determine what size to send them.

If the returned size is the same as the child container's current

size, viewWillTransitionToSize:withTransitionCoordinator: will not be

called.

*/

- (CGSize)sizeForChildContentContainer:(id)container withParentContainerSize:(CGSize)parentSizeNS_AVAILABLE_IOS(8_0);

//14.同上,依舊因?yàn)閕OS8上size class概念的提出闰非,UIViewConteroller支持了UIConntentContainer這樣一組新的協(xié)議膘格,重寫這些方法可以調(diào)整視圖布局,一個(gè)容器viewController可以使用這個(gè)方法設(shè)置childViewController的size财松,當(dāng)容器viewControllerViewWillTransitionTosize:withTransitionCoordinator:被調(diào)用時(shí)(我們重寫這個(gè)方法時(shí)要調(diào)用super)瘪贱,sizeForChildContentContainer方法將被調(diào)用。然后我們可以把需要設(shè)置desire發(fā)送給childViewController辆毡。當(dāng)我們?cè)O(shè)置的這個(gè)size和當(dāng)前childViewController的size一樣菜秦,那么childViewController的viewWillTransitionToSize方法將不會(huì)被調(diào)用。sizeForChildContentContainer默認(rèn)的實(shí)現(xiàn)是返回parentSize

/*

This method is called when the view controller's view's size is

changed by its parent (i.e. for the root view controller when its window

rotates or is resized).

If you override this method, you should either call super to

propagate the change to children or manually forward the change to

children.

*/

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinatorNS_AVAILABLE_IOS(8_0);

//15.viewController的view的size被他的parentController改變時(shí)舶掖,會(huì)觸發(fā)這個(gè)方法(比如rootViewController在它的window旋轉(zhuǎn)的時(shí)候)我們重寫這個(gè)方法時(shí)球昨,確保要調(diào)用super來(lái)保證size改變的這條消息能夠正常傳遞給它的views活著childViewControllers。

/*

This method is called when the view controller's trait collection is changed by its parent.

If you override this method, you should either call super to

propagate the change to children or manually forward the change to

children.

*/

- (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id)coordinatorNS_AVAILABLE_IOS(8_0);

//17.當(dāng)viewController的traitCollection的值將要改變時(shí)會(huì)調(diào)用這個(gè)方法眨攘,這個(gè)方法是在UITraitEnvironment協(xié)議方法traitCollectionDidChange:之前被調(diào)用主慰。我們?cè)谥貙戇@個(gè)方法時(shí)候也要確保要調(diào)用super來(lái)保證消息的傳遞。比如鲫售,我們可以像這樣在traintCollection值改變時(shí)共螺,對(duì)試圖做相應(yīng)的動(dòng)畫進(jìn)行調(diào)整。

@end

// Sometimes view controllers that are using showViewController:sender and showDetailViewController:sender: will need to know when the split view controller environment above it has changed. This notification will be posted when that happens (for example, when a split view controller is collapsing or expanding). The NSNotification's object will be the view controller that caused the change.

UIKIT_EXTERNNSString *constUIViewControllerShowDetailTargetDidChangeNotificationNS_AVAILABLE_IOS(8_0);

//18.

NS_CLASS_AVAILABLE_IOS(2_0)@interfaceUIViewController : UIResponder {

//19.UIViewController繼承自UIResponder類情竹,并實(shí)現(xiàn)NSCoding(實(shí)現(xiàn)歸檔操作)藐不,UIAppearanceContainer(允許開發(fā)者對(duì)UI控件通過(guò)定制都可以呈現(xiàn)各種外觀),UITraitEnvironment(SizeClasses適配理念鲤妥,通過(guò)內(nèi)部的traitCollection屬性佳吞,可以拿到對(duì)應(yīng)的UITraitCollection對(duì)象,從而得知當(dāng)前的SizeClass棉安,進(jìn)一步確定界面的布局)底扳,UIContentContainer協(xié)議(調(diào)整視圖布局)

@package

//20.實(shí)例變量范圍類型@package,對(duì)于framework內(nèi)部相當(dāng)于@protect贡耽,對(duì)于framework外部相當(dāng)于@private衷模。

UIView ? ? ? ? ? *_view;

//21.view成員變量

UITabBarItem ? ? *_tabBarItem;

//22.分欄控制器的item按鈕成員變量

UINavigationItem *_navigationItem;

//23.導(dǎo)航欄item成員變量

NSArray? ? ? ? ? *_toolbarItems;

//24.數(shù)組用來(lái)保存工具條按鈕item的成員變量

NSString ? ? ? ? *_title;

//25.標(biāo)題title成員變量

NSString ? ? ? ? *_nibName;

//26.nib名稱成員變量

NSBundle ? ? ? ? *_nibBundle;

//27.bundle成員變量

UIViewController *_parentViewController;// Nonretained

//28.取父viewConreoller成員變量

UIViewController *_childModalViewController;

//29.取子模態(tài)ViewController成員變量

UIViewController *_parentModalViewController;// Nonretained

//30.取父模態(tài)ViewController成員變量

UIViewController *_previousRootViewController;// Nonretained

//31.取上一個(gè)根previous的成員變量

UIView ? ? ? ? ? *_modalTransitionView;

//32.模態(tài)過(guò)渡view的成員變量

UIResponder*_modalPreservedFirstResponder;

//33.第一個(gè)保存Responder成員變量

id_dimmingView;

//34.變暗的view-----------

id_dropShadowView;

//35.刪除陰影view成員變量--------------

id_currentAction;

//36.當(dāng)前動(dòng)作方法

UIStoryboard ? ? *_storyboard;

//37.storyboard成員變量

NSArray? ? ? ? ? *_storyboardSegueTemplates;

//38.存放storyboardSegue的數(shù)組

NSDictionary ? ? *_externalObjectsTableForViewLoading;

//39.--------------------

NSArray? ? ? ? ? *_topLevelObjectsToKeepAliveFromStoryboard;

//40.--------------------

UIView ? ? ? ? ? *_savedHeaderSuperview;

//41.表頭的父view

UIView ? ? ? ? ? *_savedFooterSuperview;

//42.表尾的父view

UIBarButtonItem? *_editButtonItem;

//43.可編輯的BarButtonItem

UISearchDisplayController *_searchDisplayController;

//44.用于搜索的viewController

UIModalTransitionStyle _modalTransitionStyle;

//45.模態(tài)視圖過(guò)渡動(dòng)畫樣式

UIModalPresentationStyle _modalPresentationStyle;

//46.模態(tài)視圖呈現(xiàn)樣式

UIInterfaceOrientation _lastKnownInterfaceOrientation;

//47.當(dāng)前程序界面的旋轉(zhuǎn)方向

UIPopoverController*? ? _popoverController;

//48.IPad專用的一種臨時(shí)視圖鹊汛,以漂浮的形式出現(xiàn)在屏幕表面。

UIView *_containerViewInSheet;

//49.---------------

CGSize _contentSizeForViewInPopover;

//50.在IPad臨時(shí)視圖中展示容納的view大小

CGSize _formSheetSize;

//51.---------

UIScrollView *_recordedContentScrollView;

//52.-----------

void(^_afterAppearance)(void);

//53.---------------

NSInteger _explicitAppearanceTransitionLevel;

//54.------------

NSArray *_keyCommands;

//55.------------

NSMapTable *_overrideTraitCollections;

//56.--------了解過(guò)還是不太理解

/*

The designated initializer. If you subclass UIViewController, you must call the super implementation of this

method, even if you aren't using a NIB.? (As a convenience, the default init method will do this for you,

and specify nil for both of this methods arguments.) In the specified NIB, the File's Owner proxy should

have its class set to your view controller subclass, with the view outlet connected to the main view. If you

invoke this method with a nil nib name, then this class' -loadView method will attempt to load a NIB whose

name is the same as your view controller's class. If no such NIB in fact exists then you must either call

-setView: before -view is invoked, or override the -loadView method to set up your views programatically.

*/

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

//100.這個(gè)方法是加載對(duì)應(yīng)nibName的viewController

@property(nonatomic,retain) UIView *view;// The getter first invokes [self loadView] if the view hasn't been set yet. Subclasses must call super if they override the setter or getter.

//101.view屬性阱冶,如果當(dāng)你第一次調(diào)用[self loadView]方法而view還沒有被設(shè)置刁憋,子類必須要調(diào)用super父類方法重寫覆蓋setter和getter

- (void)loadView;// This is where subclasses should create their custom view hierarchy if they aren't using a nib. Should never be called directly.

//102.在loadView方法內(nèi)部可以創(chuàng)建自定義的view,有一前提是沒有使用xib木蹬。還有這個(gè)方法絕對(duì)不能直接主動(dòng)去調(diào)用至耻。

- (void)viewWillUnloadNS_DEPRECATED_IOS(5_0,6_0);

//103.view將要銷毀的時(shí)候會(huì)調(diào)用這個(gè)方法(不過(guò)現(xiàn)在已棄用)

- (void)viewDidUnloadNS_DEPRECATED_IOS(3_0,6_0);// Called after the view controller's view is released and set to nil. For example, a memory warning which causes the view to be purged. Not invoked as a result of -dealloc.

//104.view已經(jīng)被銷毀的時(shí)候會(huì)調(diào)用這個(gè)方法(現(xiàn)在也已棄用)

- (void)viewDidLoad;// Called after the view has been loaded. For view controllers created in code, this is after -loadView. For view controllers unarchived from a nib, this is after the view is set.

//105.這個(gè)方法在view加載完畢的時(shí)候調(diào)用,在此方法內(nèi)部對(duì)view做一些渲染的事情镊叁,做一些初始化的操作尘颓,并且執(zhí)行順序是在loadView方法調(diào)用之后調(diào)用,

- (BOOL)isViewLoadedNS_AVAILABLE_IOS(3_0);

//106.判斷view是否被加載完畢

@property(nonatomic, readonly, copy) NSString *nibName;// The name of the nib to be loaded to instantiate the view.

//107.nibName作為屬性晦譬,加載對(duì)應(yīng)的nib疤苹。

@property(nonatomic, readonly, retain) NSBundle *nibBundle;// The bundle from which to load the nib.

//108.bundle是一個(gè)資源目錄,包含nib文件敛腌,nibBunlde作為屬性

@property(nonatomic, readonly, retain) UIStoryboard *storyboardNS_AVAILABLE_IOS(5_0);

//109.storyboard屬性,iOS5出現(xiàn)

- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)senderNS_AVAILABLE_IOS(5_0);

//110.使用stortboard時(shí)利用segue進(jìn)行頁(yè)面跳轉(zhuǎn)的方法

- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)senderNS_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.

//111.這份方法是決定是否執(zhí)行segeue的關(guān)鍵卧土。可在內(nèi)部做一些時(shí)間判斷像樊,返回yes尤莺,將執(zhí)行performSegueWithIdentifier:方法,返回no不執(zhí)行performSegueWithIdentifier:凶硅,默認(rèn)返回yes缝裁,可以執(zhí)行

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)senderNS_AVAILABLE_IOS(5_0);

//112.當(dāng)用storyboard并且觸發(fā)segue時(shí)扫皱,系統(tǒng)會(huì)自動(dòng)調(diào)用這個(gè)方法足绅,可以重寫這個(gè)方法,在內(nèi)部做一些類與類傳遞數(shù)據(jù)的操作

// View controllers will receive this message during segue unwinding. The default implementation returns the result of -respondsToSelector: - controllers can override this to perform any ancillary checks, if necessary.

- (BOOL)canPerformUnwindSegueAction:(SEL)action fromViewController:(UIViewController *)fromViewController withSender:(id)senderNS_AVAILABLE_IOS(6_0);

//113.我們一般在子控制器中通過(guò)實(shí)現(xiàn)canperformUnwindSegueAction:fromViewController:withSender:來(lái)決定要不要執(zhí)行相應(yīng)的Unwind Segue韩脑。

// Custom containers should override this method and search their children for an action handler (using -canPerformUnwindSegueAction:fromViewController:sender:). If a handler is found, the controller should return it. Otherwise, the result of invoking super's implementation should be returned.

- (UIViewController *)viewControllerForUnwindSegueAction:(SEL)action fromViewController:(UIViewController *)fromViewController withSender:(id)senderNS_AVAILABLE_IOS(6_0);

//114.這個(gè)方法用來(lái)決定哪個(gè)viewController來(lái)處理Unwind Segue action

// Custom container view controllers should override this method and return segue instances that will perform the navigation portion of segue unwinding.

- (UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifierNS_AVAILABLE_IOS(6_0);

//115.這個(gè)方法用來(lái)返回自定義的Unwind Segue實(shí)例

- (void)viewWillAppear:(BOOL)animated;// Called when the view is about to made visible. Default does nothing

//116.這個(gè)方法是當(dāng)view將要顯示的時(shí)候被調(diào)用

- (void)viewDidAppear:(BOOL)animated;// Called when the view has been fully transitioned onto the screen. Default does nothing

//117.這個(gè)方法是當(dāng)view已經(jīng)顯示的時(shí)候被調(diào)用

- (void)viewWillDisappear:(BOOL)animated;// Called when the view is dismissed, covered or otherwise hidden. Default does nothing

//118.這個(gè)方法是當(dāng)view將要消失的時(shí)候調(diào)用

- (void)viewDidDisappear:(BOOL)animated;// Called after the view was dismissed, covered or otherwise hidden. Default does nothing

//119.這個(gè)方法是當(dāng)view已經(jīng)消失的時(shí)候調(diào)用

// Called just before the view controller's view's layoutSubviews method is invoked. Subclasses can implement as necessary. The default is a nop.

- (void)viewWillLayoutSubviewsNS_AVAILABLE_IOS(5_0);

//120.在重新布局子view前的時(shí)候會(huì)調(diào)用

// Called just after the view controller's view's layoutSubviews method is invoked. Subclasses can implement as necessary. The default is a nop.

- (void)viewDidLayoutSubviewsNS_AVAILABLE_IOS(5_0);

//120.在重新布局子view后的時(shí)候會(huì)調(diào)用

@property(nonatomic,copy) NSString *title;// Localized title for use by a parent controller.

//121.標(biāo)題title屬性

- (void)didReceiveMemoryWarning;// Called when the parent application receives a memory warning. On iOS 6.0 it will no longer clear the view by default.

//122.當(dāng)應(yīng)用程序收到內(nèi)存警告的時(shí)候會(huì)調(diào)用這個(gè)方法,做相應(yīng)的解決內(nèi)存警告的操作

/*

If this view controller is a child of a containing view controller (e.g. a navigation controller or tab bar

controller,) this is the containing view controller.? Note that as of 5.0 this no longer will return the

presenting view controller.

*/

@property(nonatomic,readonly) UIViewController *parentViewController;

//123.取父viewController的屬性

// This property has been replaced by presentedViewController.

@property(nonatomic,readonly) UIViewController *modalViewControllerNS_DEPRECATED_IOS(2_0,6_0);

//124.得到模態(tài)視圖控制器

// The view controller that was presented by this view controller or its nearest ancestor.

@property(nonatomic,readonly) UIViewController *presentedViewControllerNS_AVAILABLE_IOS(5_0);

//125.------------------------

// The view controller that presented this view controller (or its farthest ancestor.)

@property(nonatomic,readonly) UIViewController *presentingViewControllerNS_AVAILABLE_IOS(5_0);

//126.正在展示的控制器

/*

Determines which parent view controller's view should be presented over for presentations of type

UIModalPresentationCurrentContext.? If no ancestor view controller has this flag set, then the presenter

will be the root view controller.

*/

@property(nonatomic,assign)BOOLdefinesPresentationContextNS_AVAILABLE_IOS(5_0);

//127.決定哪個(gè)父viewController的view應(yīng)當(dāng)呈現(xiàn)在當(dāng)前氢妈,如果沒有父viewController,呈現(xiàn)的將是根視圖控制器段多。

// A controller that defines the presentation context can also specify the modal transition style if this property is true.

@property(nonatomic,assign)BOOLprovidesPresentationContextTransitionStyleNS_AVAILABLE_IOS(5_0);

//128.如果這個(gè)屬性是true的話首量,可以定義模態(tài)過(guò)渡轉(zhuǎn)場(chǎng)的樣式

/*

These four methods can be used in a view controller's appearance callbacks to determine if it is being

presented, dismissed, or added or removed as a child view controller. For example, a view controller can

check if it is disappearing because it was dismissed or popped by asking itself in its viewWillDisappear:

method by checking the expression ([self isBeingDismissed] || [self isMovingFromParentViewController]).

*/

- (BOOL)isBeingPresentedNS_AVAILABLE_IOS(5_0);

//129.判斷viewController是否正在展示

- (BOOL)isBeingDismissedNS_AVAILABLE_IOS(5_0);

//130.判斷viewController是否正在消失

- (BOOL)isMovingToParentViewControllerNS_AVAILABLE_IOS(5_0);

//131.判斷是否正在向父viewController移動(dòng)

- (BOOL)isMovingFromParentViewControllerNS_AVAILABLE_IOS(5_0);

//132.判斷是否正由父viewController移動(dòng)而來(lái)

/*

The next two methods are replacements for presentModalViewController:animated and

dismissModalViewControllerAnimated: The completion handler, if provided, will be invoked after the presented

controllers viewDidAppear: callback is invoked.

*/

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void(^)(void))completionNS_AVAILABLE_IOS(5_0);

//133.這個(gè)方法可以實(shí)現(xiàn)從當(dāng)前viewController模態(tài)跳轉(zhuǎn)到另一個(gè)viewController,completion可在viewDidAppear后回調(diào)

// The completion handler, if provided, will be invoked after the dismissed controller's viewDidDisappear: callback is invoked.

- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void(^)(void))completionNS_AVAILABLE_IOS(5_0);

//134.這個(gè)方法可以實(shí)現(xiàn)退出當(dāng)前viewController由模態(tài)方式展現(xiàn)出來(lái)的进苍,completion可在viewDidDisappear后回調(diào)

// Display another view controller as a modal child. Uses a vertical sheet transition if animated.This method has been replaced by presentViewController:animated:completion:

- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animatedNS_DEPRECATED_IOS(2_0,6_0);

//135.呈現(xiàn)模態(tài)視圖

// Dismiss the current modal child. Uses a vertical sheet transition if animated. This method has been replaced by dismissViewControllerAnimated:completion:

- (void)dismissModalViewControllerAnimated:(BOOL)animatedNS_DEPRECATED_IOS(2_0,6_0);

//136.退出模態(tài)視圖

/*

Defines the transition style that will be used for this view controller when it is presented modally. Set

this property on the view controller to be presented, not the presenter.? Defaults to

UIModalTransitionStyleCoverVertical.

*/

@property(nonatomic,assign) UIModalTransitionStyle modalTransitionStyleNS_AVAILABLE_IOS(3_0);

//137.當(dāng)一個(gè)viewController以模態(tài)方式呈現(xiàn)的時(shí)候加缘,通過(guò)modalTransitionStyle可設(shè)置過(guò)渡動(dòng)畫樣式

@property(nonatomic,assign) UIModalPresentationStyle modalPresentationStyleNS_AVAILABLE_IOS(3_2);

//137.當(dāng)一個(gè)viewController以模態(tài)方式呈現(xiàn)的時(shí)候,通過(guò)modalPresentationStyle可設(shè)置呈現(xiàn)的樣式

// This controls whether this view controller takes over control of the status bar's appearance when presented non-full screen on another view controller. Defaults to NO.

@property(nonatomic,assign)BOOLmodalPresentationCapturesStatusBarAppearanceNS_AVAILABLE_IOS(7_0);

//138.這個(gè)屬性是控制是否顯示狀態(tài)欄

// Presentation modes may keep the keyboard visible when not required. Default implementation affects UIModalPresentationFormSheet visibility.

- (BOOL)disablesAutomaticKeyboardDismissalNS_AVAILABLE_IOS(4_3);

//139.這個(gè)API是于關(guān)閉鍵盤相關(guān)的觉啊,通常情況下單純的使用resignFirstResponder即可關(guān)閉鍵盤拣宏,但是在UIModalPresentationFormSheet下的視圖是無(wú)法用resignFirstResponder這個(gè)API,是因?yàn)樵谶M(jìn)入到此模式后杠人,系統(tǒng)將disablesAutomaticKeyboardDismissal的方法返回值設(shè)置成了YES勋乾,所以解決方法很簡(jiǎn)單宋下,重新實(shí)現(xiàn)disablesAutomaticKeyboardDismissal,如果是直接使用viewController則可以在實(shí)現(xiàn)文件中重新實(shí)現(xiàn)這個(gè)API辑莫,將返回改為NO后学歧,即可正常使用resignFirstResponder方法隱藏鍵盤,但很多時(shí)候我們是把viewController放在UINavigationController中的各吨,這種情況下直接在viewController這里面實(shí)現(xiàn)disablesAutomaticKeyboardDismissal依然失效枝笨,而應(yīng)發(fā)iUINavigationController中實(shí)現(xiàn)這個(gè)API。

@property(nonatomic,assign)BOOLwantsFullScreenLayoutNS_DEPRECATED_IOS(3_0,7_0);// Deprecated in 7_0, Replaced by the following:

//140.wantsFullScreenLayout=true揭蜒,狀態(tài)欄的高度就不會(huì)被算在視圖里伺帘,也就是說(shuō)有沒有狀態(tài)欄y坐標(biāo)始終都是從0算起(不過(guò)此屬性在iOS7已被棄用,下面屬性替代此功能)

@property(nonatomic,assign) UIRectEdge edgesForExtendedLayoutNS_AVAILABLE_IOS(7_0);// Defaults to UIRectEdgeAll

//141.iOS7的新屬性忌锯,默認(rèn)值為UIRectEdgeAll伪嫁,在navigationController中view的默認(rèn)布局從navigationBar開始,self.edgesForExtendedLayout=UIRectEdgeNone,則布局控件減去navigationBar----------------

@property(nonatomic,assign)BOOLextendedLayoutIncludesOpaqueBarsNS_AVAILABLE_IOS(7_0);// Defaults to NO, but bars are translucent(透明的偶垮,半透明的)by default on 7_0.

//142.在iOS7中UIViewController的wantsFullScreenLayout已經(jīng)被舍棄张咳,不在提供控件自動(dòng)展示到導(dǎo)航欄下面這個(gè)屬性,所有的UIViewController創(chuàng)建后默認(rèn)就是full

Screen的似舵,因此如果帶導(dǎo)航欄的應(yīng)用界面中的部分控件會(huì)被導(dǎo)航欄覆蓋掉脚猾,要解決這個(gè)情況可以使用iOS7中UIVIewController新增的屬性extendedLayoutIncludesOpaqueBars和edgesForExtendedLayout來(lái)解決。其中這個(gè)屬性指定了當(dāng)bar使用了不透明圖片時(shí)砚哗,視圖是否眼神至bar所在區(qū)域龙助,默認(rèn)值是NO,而edgesForExtendedLayout則是表示食欲是夠覆蓋到四周的區(qū)域蛛芥,默認(rèn)是UIRectEdgeAll提鸟,即上下左右四個(gè)方向都會(huì)覆蓋,那么為讓頂部不進(jìn)行眼神到導(dǎo)航欄覆蓋的區(qū)域仅淑,我們可以把頂部區(qū)域眼神去掉称勋,實(shí)現(xiàn)代碼如下,self.extendedLayoutIncludesOpaqueBars

= NO;

self.edgesForExtendedLayout = UIRectEdgeBottom | UIRectEdgeLeft | UIRectEdgeRight;

當(dāng)你在做的時(shí)候發(fā)現(xiàn)viewDidLoad的時(shí)候view的高度還是全屏涯竟,viewWillAppear已經(jīng)去掉navigationbar了赡鲜,所以frame的設(shè)置放在了viewWillAppear中比較準(zhǔn)確。

@property(nonatomic,assign)BOOLautomaticallyAdjustsScrollViewInsetsNS_AVAILABLE_IOS(7_0);// Defaults to YES

//143.當(dāng)在一個(gè)viewController中有多個(gè)tableView之類的時(shí)候庐船,要把這個(gè)屬性設(shè)置為NO银酬,這樣多個(gè)tableview的位置就會(huì)是按照自己設(shè)定的來(lái),而不會(huì)出現(xiàn)位置意外不對(duì)的情況

/* The preferredContentSize is used for any container laying out a child view controller.

*/

@property(nonatomic) CGSize preferredContentSizeNS_AVAILABLE_IOS(7_0);

//144.preferredContentSize來(lái)設(shè)置我們期望的childViewController的界面的大小

// These methods control the attributes of the status bar when this view controller is shown. They can be overridden in view controller subclasses to return the desired status bar attributes.

- (UIStatusBarStyle)preferredStatusBarStyleNS_AVAILABLE_IOS(7_0);// Defaults to UIStatusBarStyleDefault

//145.設(shè)置shown的ViewController的狀態(tài)欄樣式

- (BOOL)prefersStatusBarHiddenNS_AVAILABLE_IOS(7_0);// Defaults to NO

//146.設(shè)置狀態(tài)欄是否隱藏顯示

// Override to return the type of animation that should be used for status bar changes for this view controller. This currently only affects changes to prefersStatusBarHidden.

- (UIStatusBarAnimation)preferredStatusBarUpdateAnimationNS_AVAILABLE_IOS(7_0);// Defaults to UIStatusBarAnimationFade

//147.重寫此方法設(shè)置狀態(tài)欄更新時(shí)候的動(dòng)畫

// This should be called whenever the return values for the view controller's status bar attributes have changed. If it is called from within an animation block, the changes will be animated along with the rest of the animation block.

- (void)setNeedsStatusBarAppearanceUpdateNS_AVAILABLE_IOS(7_0);

//148.如果需要對(duì)狀態(tài)欄進(jìn)行刷新筐钟,調(diào)用此方法即可

/* This method returns either itself or the nearest ancestor that responds to the action. View controllers can return NO from canPerformAction:withSender: to opt out of being a target for a given action. */

- (UIViewController *)targetViewControllerForAction:(SEL)action sender:(id)senderNS_AVAILABLE_IOS(8_0);

//149.

/* This method will show a view controller appropriately for the current size-class environment. It's implementation calls

`[self targetViewControllerForAction:sender:]` first and redirects

accordingly if the return value is not `self`, otherwise it will present

the vc. */

- (void)showViewController:(UIViewController *)vc sender:(id)senderNS_AVAILABLE_IOS(8_0);

//150.-----------------

/* This method will show a view controller within the semantic "detail" UI associated with the current size-class environment. It's implementation calls? `[self targetViewControllerForAction:sender:]` first and redirects accordingly if the return value is not `self`, otherwise it will present the vc.? */

- (void)showDetailViewController:(UIViewController *)vc sender:(id)senderNS_AVAILABLE_IOS(8_0);

//151.--------------------------

@end

// To make it more convenient for applications to adopt rotation, a view controller may implement the below methods. Your UIWindow's frame should use [UIScreen mainScreen].bounds as its frame.

@interfaceUIViewController (UIViewControllerRotation)

//152.為UIViewController添加分類方法為了更好的適應(yīng)應(yīng)用的屏幕旋轉(zhuǎn)

// call this method when your return value from shouldAutorotateToInterfaceOrientation: changes

// if the current interface orientation does not match the current device orientation, a rotation may occur provided all relevant view controllers now return YES from shouldAutorotateToInterfaceOrientation:

+ (void)attemptRotationToDeviceOrientationNS_AVAILABLE_IOS(5_0);

//153.這個(gè)方法這樣使用:當(dāng)應(yīng)用的device orientation轉(zhuǎn)換方向揩瞪,又希望interface orientation也跟著轉(zhuǎn)換方向時(shí),不僅僅是將supportedInterfaceOrientations的返回值設(shè)置為目標(biāo)方向盗棵,仍需要調(diào)用attemptRotationToDeviceOrientation這個(gè)方法壮韭,這樣才能讓interface orientation和device orientation的方向立即保持一致北发。

// Applications should use supportedInterfaceOrientations and/or shouldAutorotate..

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientationNS_DEPRECATED_IOS(2_0,6_0);

//154.iOS6之前我們可以通過(guò)這個(gè)方法來(lái)單獨(dú)控制某個(gè)UIVewController的旋轉(zhuǎn)方向

// New Autorotation support.

- (BOOL)shouldAutorotateNS_AVAILABLE_IOS(6_0);

//155.決定是否之處多方向旋轉(zhuǎn)屏,返回NO不支持喷屋,只會(huì)支持默認(rèn)的UIInterfaceOrientaionMaskPortrait方向

- (NSUInteger)supportedInterfaceOrientationsNS_AVAILABLE_IOS(6_0);

//156.此方法的返回值決定interface orienation的旋轉(zhuǎn)方向

// Returns interface orientation masks.

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentationNS_AVAILABLE_IOS(6_0);

//157.這個(gè)方法的作用是設(shè)置viewController在present時(shí)首選的默認(rèn)方向琳拨,返回一個(gè)interfaceOrientation

// The rotating header and footer views will slide out during the rotation and back in once it has completed.

- (UIView *)rotatingHeaderViewNS_DEPRECATED_IOS(2_0,8_0,"Header views are animated along with the rest of the view hierarchy");// Must be in the view hierarchy. Default returns nil.

//158.查詢當(dāng)前的導(dǎo)航視圖

- (UIView *)rotatingFooterViewNS_DEPRECATED_IOS(2_0,8_0,"Footer views are animated along with the rest of the view hierarchy");// Must be in the view hierarchy. Default returns nil.

//159.查詢當(dāng)前的標(biāo)簽視圖

@property(nonatomic,readonly) UIInterfaceOrientation interfaceOrientationNS_DEPRECATED_IOS(2_0,8_0);

//160.interfaceOrientation是應(yīng)用界面的旋轉(zhuǎn)方向

// Notifies when rotation begins, reaches halfway point and ends.

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)durationNS_DEPRECATED_IOS(2_0,8_0,"Implement viewWillTransitionToSize:withTransitionCoordinator: instead");

//161.應(yīng)用界面將要旋轉(zhuǎn)的時(shí)候前會(huì)調(diào)用,一般用來(lái)禁用某些控件或者停止某些正在運(yùn)行的動(dòng)作屯曹,比如播放視頻等等

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientationNS_DEPRECATED_IOS(2_0,8_0);

//162.這個(gè)發(fā)生在旋轉(zhuǎn)屏幕之后狱庇,一般用來(lái)啟用某些之前被禁用的控件或者是之前已經(jīng)正在運(yùn)行的動(dòng)作,如播放視頻等等

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)durationNS_DEPRECATED_IOS(3_0,8_0,"Implement viewWillTransitionToSize:withTransitionCoordinator: instead");

//163.這個(gè)方法發(fā)生在旋轉(zhuǎn)的過(guò)程中恶耽,一般用來(lái)定制翻轉(zhuǎn)后各個(gè)控件的位置大小等

- (void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)durationNS_DEPRECATED_IOS(2_0,5_0);

//164.這個(gè)方法和163那個(gè)方法作用一樣密任,就是作用范圍時(shí)間不一樣,作為翻轉(zhuǎn)的前半段

- (void)didAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientationNS_DEPRECATED_IOS(2_0,5_0);// The rotating header and footer views are offscreen.

//165.這個(gè)方法是在前半段旋轉(zhuǎn)之后發(fā)生偷俭,做一些相應(yīng)操作

- (void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)durationNS_DEPRECATED_IOS(2_0,5_0);// A this point, our view orientation is set to the new orientation.

//166.這個(gè)方法是也是發(fā)生在旋轉(zhuǎn)過(guò)程中浪讳,和163一樣作樣,發(fā)生作用范圍在后半段

@end

// Many view controllers have a view that may be in an editing state or not- for example, a UITableView.? These view

// controllers can track the editing state, and generate an Edit|Done button to be used in a navigation bar.

@interfaceUIViewController (UIViewControllerEditing)

//167.為UIViewController添加分類方法實(shí)現(xiàn)可編輯的功能

@property(nonatomic,getter=isEditing)BOOLediting;

//168.bool值判斷是否可編輯

- (void)setEditing:(BOOL)editing animated:(BOOL)animated;// Updates the appearance of the Edit|Done button item as necessary. Clients who override it must call super first.

//169.更新Edit|Done按鈕item的外觀

- (UIBarButtonItem *)editButtonItem;// Return an Edit|Done button that can be used as a navigation item's custom view. Default action toggles the editing state with animation.

//170.實(shí)現(xiàn)一個(gè)自定義的view涌萤,作為導(dǎo)航欄的Edit|Done按鈕淹遵。

@end

@interfaceUIViewController (UISearchDisplayControllerSupport)

//171.實(shí)現(xiàn)UISearchDisplayControllerSupport相關(guān)的分類方法

@property(nonatomic, readonly, retain) UISearchDisplayController *searchDisplayControllerNS_DEPRECATED_IOS(3_0,8_0);

//172.UIViewController自帶searchDisplayController屬性

@end

/*

This exception is raised when a child view controller's view is added into the view hierarchy and the first

superview of the child view controller's view that has a view controller is NOT the child view controller's

parent.

*/

UIKIT_EXTERNNSString *constUIViewControllerHierarchyInconsistencyExceptionNS_AVAILABLE_IOS(5_0);

//173.異常。因控制器的層次與視圖的層次不一致會(huì)引發(fā)該異常负溪,當(dāng)視圖控制器的視圖添加到視圖層中透揣,系統(tǒng)會(huì)遍歷視圖層來(lái)找到第一個(gè)擁有視圖控制器的父視圖。找到的該父視圖控制器也必須是剛添加的視圖的所對(duì)應(yīng)視圖控制器的父控制器川抡。否則會(huì)拋出異常辐真。當(dāng)視圖控制器通過(guò)addChildViewController方法被添加進(jìn)來(lái)后,也會(huì)進(jìn)行之前的一致性檢測(cè)崖堤。不存在俯視圖控制器的視圖控制器侍咱,也可以將其視圖添加到視圖層中。但通常極少數(shù)情況下才會(huì)用到這種方式倘感。

/*

The methods in the UIContainerViewControllerProtectedMethods and the UIContainerViewControllerCallbacks

categories typically should only be called by subclasses which are implementing new container view

controllers. They may be overridden but must call super.

*/

@interfaceUIViewController (UIContainerViewControllerProtectedMethods)

//174.添加新類別ContainerViewController放坏,那什么是ContainerViewController咙咽,意思就是一個(gè)viewController顯示的某部分內(nèi)容屬于另一個(gè)viewController老玛,那么這個(gè)viewController就是一個(gè)container,比如UIKit的UINavigationController钧敞,UITabBarController

// An array of children view controllers. This array does not include any presented view controllers.

@property(nonatomic,readonly) NSArray *childViewControllersNS_AVAILABLE_IOS(5_0);

//175.數(shù)組用來(lái)存放子控制器

/*

If the child controller has a different parent controller, it will first be removed from its current parent

by calling removeFromParentViewController. If this method is overridden then the super implementation must

be called.

*/

- (void)addChildViewController:(UIViewController *)childControllerNS_AVAILABLE_IOS(5_0);

//176.添加子視圖控制器

/*

Removes the the receiver from its parent's children controllers array. If this method is overridden then

the super implementation must be called.

*/

- (void) removeFromParentViewControllerNS_AVAILABLE_IOS(5_0);

//177.從父控制器中移除子控制器

/*

This method can be used to transition between sibling child view controllers. The receiver of this method is

their common parent view controller. (Use [UIViewController addChildViewController:] to create the

parent/child relationship.) This method will add the toViewController's view to the superview of the

fromViewController's view and the fromViewController's view will be removed from its superview after the

transition completes. It is important to allow this method to add and remove the views. The arguments to

this method are the same as those defined by UIView's block animation API. This method will fail with an

NSInvalidArgumentException if the parent view controllers are not the same as the receiver, or if the

receiver explicitly forwards its appearance and rotation callbacks to its children. Finally, the receiver

should not be a subclass of an iOS container view controller. Note also that it is possible to use the

UIView APIs directly. If they are used it is important to ensure that the toViewController's view is added

to the visible view hierarchy while the fromViewController's view is removed.

*/

- (void)transitionFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void(^)(void))animations completion:(void(^)(BOOLfinished))completionNS_AVAILABLE_IOS(5_0);

//178.不同的view放在不同的viewController中蜡豹,用到才去創(chuàng)建,那么這個(gè)方法是實(shí)現(xiàn)兩個(gè)自控制器的切換溉苛,參數(shù)fromViewController是當(dāng)前顯示在父控制器中的子視圖控制器镜廉,toViewController是將要顯示的子視圖控制器,duration完成過(guò)渡時(shí)間愚战,options指定的過(guò)渡效果娇唯,animations動(dòng)畫齐遵,completion過(guò)渡完成后,回調(diào)的block塊操作

// If a custom container controller manually forwards its appearance callbacks, then rather than calling

// viewWillAppear:, viewDidAppear: viewWillDisappear:, or viewDidDisappear: on the children these methods

// should be used instead. This will ensure that descendent child controllers appearance methods will be

// invoked. It also enables more complex custom transitions to be implemented since the appearance callbacks are

// now tied to the final matching invocation of endAppearanceTransition.

- (void)beginAppearanceTransition:(BOOL)isAppearing animated:(BOOL)animated__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0);

//179.beginAppearanceTransition觸發(fā)相應(yīng)的viewVWillAppear塔插?梗摇??想许?伶授??流纹?糜烹??漱凝?疮蹦??

- (void)endAppearanceTransition__OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0);

//180.endAppearanceTransition觸發(fā)相應(yīng)的viewWillDisappear

// Override to return a child view controller or nil. If non-nil, that view controller's status bar appearance attributes will be used. If nil, self is used. Whenever the return values from these methods change, -setNeedsUpdatedStatusBarAttributes should be called.

- (UIViewController *)childViewControllerForStatusBarStyleNS_AVAILABLE_IOS(7_0);

//181.設(shè)置子控制器的狀態(tài)欄樣式

- (UIViewController *)childViewControllerForStatusBarHiddenNS_AVAILABLE_IOS(7_0);

//182.實(shí)現(xiàn)此方法來(lái)指定要控制的狀態(tài)欄隱藏和取消隱藏狀態(tài)

// Call to modify the trait collection for child view controllers.

- (void)setOverrideTraitCollection:(UITraitCollection *)collection forChildViewController:(UIViewController *)childViewControllerNS_AVAILABLE_IOS(8_0);

//183.通過(guò)此方法可以為子控制器重新設(shè)置traintCollection的值茸炒,一般情況下traitCollection值從父controller傳到子controller是不做修改的挚币,而我們自己實(shí)現(xiàn)一個(gè)容器controller的時(shí)候,我們可以使用這個(gè)方法進(jìn)行調(diào)整

- (UITraitCollection *)overrideTraitCollectionForChildViewController:(UIViewController *)childViewControllerNS_AVAILABLE_IOS(8_0);

//184.這個(gè)方法可以幫助我們獲得子控制器的trainCollection值扣典。

@end

@interfaceUIViewController (UIContainerViewControllerCallbacks)

//185.關(guān)于ContainerViewController一些回調(diào)方法

/*

This method is consulted to determine if a view controller manually forwards its containment callbacks to

any children view controllers. Subclasses of UIViewController that implement containment logic may override

this method. The default implementation returns YES. If it is overridden and returns NO, then the subclass is

responsible for forwarding the following methods as appropriate - viewWillAppear: viewDidAppear: viewWillDisappear:

viewDidDisappear: willRotateToInterfaceOrientation:duration:

willAnimateRotationToInterfaceOrientation:duration: didRotateFromInterfaceOrientation:

*/

- (BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllersNS_DEPRECATED_IOS(5_0,6_0);

//186.在iOS5中覆蓋此方法可以關(guān)閉appearance callbacks的自動(dòng)傳遞特性

- (BOOL)shouldAutomaticallyForwardRotationMethodsNS_DEPRECATED_IOS(6_0,8_0,"Manually forward viewWillTransitionToSize:withTransitionCoordinator: if necessary");

//187.在iOS6之后妆毕,覆蓋此方法可以禁止掉旋轉(zhuǎn)回調(diào)自動(dòng)傳遞的特性(因?yàn)橛袝r(shí)候作為容器的childViewController可能不需要這些方法傳遞給所有的childViewControllers,只需要傳遞給正在顯示的childVieControllrer)

- (BOOL)shouldAutomaticallyForwardAppearanceMethodsNS_AVAILABLE_IOS(6_0);

//188.在iOS6之后需要覆蓋整個(gè)方法來(lái)關(guān)閉appearance callbacks的自動(dòng)傳遞特性

/*

These two methods are public for container subclasses to call when transitioning between child

controllers. If they are overridden, the overrides should ensure to call the super. The parent argument in

both of these methods is nil when a child is being removed from its parent; otherwise it is equal to the new

parent view controller.

addChildViewController: will call [child willMoveToParentViewController:self] before adding the

child. However, it will not call didMoveToParentViewController:. It is expected that a container view

controller subclass will make this call after a transition to the new child has completed or, in the

case of no transition, immediately after the call to addChildViewController:. Similarly

removeFromParentViewController: does not call [self willMoveToParentViewController:nil] before removing the

child. This is also the responsibilty of the container subclass. Container subclasses will typically define

a method that transitions to a new child by first calling addChildViewController:, then executing a

transition which will add the new child's view into the view hierarchy of its parent, and finally will call

didMoveToParentViewController:. Similarly, subclasses will typically define a method that removes a child in

the reverse manner by first calling [child willMoveToParentViewController:nil].

*/

- (void)willMoveToParentViewController:(UIViewController *)parentNS_AVAILABLE_IOS(5_0);

//189.當(dāng)addChildViewController:接口建立了邏輯上的父子關(guān)系贮尖,接口的邏輯中會(huì)自動(dòng)調(diào)用willMoveToParentViewController這個(gè)方法笛粘,在即將移動(dòng)顯示ParentViewController的時(shí)候調(diào)用

- (void)didMoveToParentViewController:(UIViewController *)parentNS_AVAILABLE_IOS(5_0);

//190.這個(gè)方法和上面這個(gè)方法類似,在移動(dòng)顯示ParentViewController之后自動(dòng)調(diào)用

@end

@interfaceUIViewController (UIStateRestoration)

//191.UIStateRestoration提供持久數(shù)據(jù)的接口

@property(nonatomic, copy) NSString *restorationIdentifierNS_AVAILABLE_IOS(6_0);

//192.這個(gè)屬性是用來(lái)標(biāo)示是否支持保存湿硝,恢復(fù)視圖狀態(tài)信息

@property(nonatomic, readwrite, assign) Class restorationClassNS_AVAILABLE_IOS(6_0);

//193.

- (void) encodeRestorableStateWithCoder:(NSCoder *)coderNS_AVAILABLE_IOS(6_0);

//194.保存視圖狀態(tài)相關(guān)信息

- (void) decodeRestorableStateWithCoder:(NSCoder *)coderNS_AVAILABLE_IOS(6_0);

//195.恢復(fù)和保持視圖狀態(tài)相關(guān)信息

- (void) applicationFinishedRestoringStateNS_AVAILABLE_IOS(7_0);

//196.其他對(duì)象解碼完成后薪前,系統(tǒng)會(huì)調(diào)用此方法

@end

@interfaceUIViewController (UIConstraintBasedLayoutCoreMethods)

//197.增加分類基于布局約束的核心方法

/* Base implementation sends -updateConstraints to the view.

When a view has a view controller, this message is sent to the view controller during

the autolayout updateConstraints pass in lieu of sending updateConstraints directly

to the view.

You may override this method in a UIViewController subclass for updating custom

constraints instead of subclassing your view and overriding -[UIView updateConstraints].

Overrides must call super or send -updateConstraints to the view.

*/

- (void)updateViewConstraintsNS_AVAILABLE_IOS(6_0);

//198.更新布局約束的方法,viewController的view再更新視圖布局時(shí)关斜,會(huì)先調(diào)用這個(gè)方法示括,可以通過(guò)重寫這個(gè)方法去更新當(dāng)前view的內(nèi)部布局,而不用再繼承這個(gè)view去重寫updateConstraints方法痢畜,記得注意重寫時(shí)垛膝,要調(diào)用super或者調(diào)用當(dāng)前view的updateContraints方法。

@end

@protocolUIViewControllerTransitioningDelegate;

//199.viewController過(guò)渡的代理協(xié)議

@interfaceUIViewController(UIViewControllerTransitioning)

@property(nonatomic,assign)id transitioningDelegateNS_AVAILABLE_IOS(7_0);

//200.實(shí)例化協(xié)議屬性

@end

@interfaceUIViewController (UILayoutSupport)

// These objects may be used as layout items in the NSLayoutConstraint API

@property(nonatomic,readonly,retain)id topLayoutGuideNS_AVAILABLE_IOS(7_0);

//201.這個(gè)屬性是通過(guò)計(jì)算viewController->view->top到覆蓋這個(gè)view最下層的那個(gè)bar-》bottom的距離

@property(nonatomic,readonly,retain)id bottomLayoutGuideNS_AVAILABLE_IOS(7_0);

//202.這個(gè)屬性是通過(guò)計(jì)算viewController->view->bottom到覆蓋這個(gè)biew上層那個(gè)bar-top的距離

@end

@classNSExtensionContext;//丁稀?吼拥??线衫?凿可??授账?枯跑?惨驶??敛助?敞咧??辜腺?休建??评疗?测砂??百匆?砌些??加匈?存璃??雕拼?纵东??啥寇?偎球??辑甜?衰絮??磷醋?猫牡?

//203.引入NSExtensionContext類,iOS8新增的一個(gè)跨站上下文屬性的extensionContext邓线,來(lái)處理containing app與擴(kuò)展之間的通信淌友,上下文的類型是NSExtensionContext。

@interfaceUIViewController(NSExtensionAdditions)

//204.添加分類并且綁定協(xié)議

// Returns the extension context. Also acts as a convenience method for a view controller to check if it participating in an extension request.

@property(nonatomic,readonly,retain) NSExtensionContext *extensionContextNS_AVAILABLE_IOS(8_0);

//205.實(shí)例化NSExtensionContext屬性

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末褂痰,一起剝皮案震驚了整個(gè)濱河市亩进,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌缩歪,老刑警劉巖,帶你破解...
    沈念sama閱讀 206,126評(píng)論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件谍憔,死亡現(xiàn)場(chǎng)離奇詭異匪蝙,居然都是意外死亡主籍,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,254評(píng)論 2 382
  • 文/潘曉璐 我一進(jìn)店門逛球,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)千元,“玉大人,你說(shuō)我怎么就攤上這事颤绕⌒液#” “怎么了?”我有些...
    開封第一講書人閱讀 152,445評(píng)論 0 341
  • 文/不壞的土叔 我叫張陵奥务,是天一觀的道長(zhǎng)物独。 經(jīng)常有香客問(wèn)我,道長(zhǎng)氯葬,這世上最難降的妖魔是什么挡篓? 我笑而不...
    開封第一講書人閱讀 55,185評(píng)論 1 278
  • 正文 為了忘掉前任,我火速辦了婚禮帚称,結(jié)果婚禮上官研,老公的妹妹穿的比我還像新娘。我一直安慰自己闯睹,他們只是感情好戏羽,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,178評(píng)論 5 371
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著楼吃,像睡著了一般蛛壳。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上所刀,一...
    開封第一講書人閱讀 48,970評(píng)論 1 284
  • 那天衙荐,我揣著相機(jī)與錄音,去河邊找鬼浮创。 笑死忧吟,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的斩披。 我是一名探鬼主播溜族,決...
    沈念sama閱讀 38,276評(píng)論 3 399
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼垦沉!你這毒婦竟也來(lái)了煌抒?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 36,927評(píng)論 0 259
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤厕倍,失蹤者是張志新(化名)和其女友劉穎寡壮,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 43,400評(píng)論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡况既,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 35,883評(píng)論 2 323
  • 正文 我和宋清朗相戀三年这溅,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片棒仍。...
    茶點(diǎn)故事閱讀 37,997評(píng)論 1 333
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡悲靴,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出莫其,到底是詐尸還是另有隱情癞尚,我是刑警寧澤,帶...
    沈念sama閱讀 33,646評(píng)論 4 322
  • 正文 年R本政府宣布乱陡,位于F島的核電站浇揩,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏蛋褥。R本人自食惡果不足惜临燃,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,213評(píng)論 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望烙心。 院中可真熱鬧膜廊,春花似錦、人聲如沸淫茵。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,204評(píng)論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至,卻和暖如春迹恐,著一層夾襖步出監(jiān)牢的瞬間契耿,已是汗流浹背椒惨。 一陣腳步聲響...
    開封第一講書人閱讀 31,423評(píng)論 1 260
  • 我被黑心中介騙來(lái)泰國(guó)打工碌奉, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人碍论。 一個(gè)月前我還...
    沈念sama閱讀 45,423評(píng)論 2 352
  • 正文 我出身青樓谅猾,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親鳍悠。 傳聞我的和親對(duì)象是個(gè)殘疾皇子税娜,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,722評(píng)論 2 345

推薦閱讀更多精彩內(nèi)容