UIViewController Summary

1, self.view first use, will use loadView initialized and triggered after viewdidload complete, continue to operate self.view


IOS6.0, the abandoned viewDidUnload and viewWillUnload ... so only use  didReceiveMemoryWarning
In the previous ios, didReceiveMemoryWarning triggers viewDidUnload, etc., but now, can only deal with their own in-memory warnings, and even their own release self.view. . If you do release sefl.view = nil. At the time of loading will re-trigger viewDidload

2, the hand tabviewcontroller, navigationcontroller viewWillAppear other message transmission, which will result in a message sent to its namesake stack viewcontroller.

As ViewController container used does not have this characteristic, because it (the action addsubview) issued viewWillAppear system sends all its container after 5.0 childController

3, the initialization process tableViewController: viewWillAppear -> tableViewDatasource method -> viewDidAppear
Since the update data source is preferably carried out in viewWillAppear, and the reloadData ... ..
.. After the viewDidLoad viewWillAppear prior to reloadData

After 4. pushcontroller will trigger viewdidload

ios- hide the status bar

Add a property in the project .plist file  Status bar IS INITIALLY hidden , property values can be set to YES    

Status Bar. . The network connection appears chrysanthemum. .
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES 


1, memory warning and viewDidUnload in the unit controller transmits (sequential order of the stack of the navigation controller) to all the controller. But the front desk controller will not receive viewDidUnload, navigation controller is not a background controller, you do not receive viewDidUnload
The view controller calls its  viewDidUnload  method to inform subclasses that the self.view were removed. A subclass typically uses this method to release any strong references it has to self.view.

2、 When overriding the loadView method to create your views programmatically,you should not call  super.  Doing so initiates the default view-loading behavior and usually just wastes CPU cycles. Your own implementation of the  loadView  method should do all the work that is needed to create a root view and subviews for your view controller.

You realized loadView method in the controller, then you might be memory management control call sometime applications running. If time is insufficient device memory, view controller will receive didReceiveMemoryWarning news. The default implementation is to check whether the current view controller in use. If it's not in the view hierarchy view currently being used inside, and your controller implements loadView method, then the view will be release, loadView method will be called again to create a new view. 
The default implementation of this method is this: to look for information on available nib file, based on this information to load the nib file, if there is no information about the nib file, the default implementation creates an empty UIView object, and then let the object becomes controller the main view.

3、 If the autoresizing behaviors of views do not provide the precise layout you need, you may want to replace or supplement their behavior by providing your own custom layout code. The  UIViewController  class and the  UIView  class each define methods that are called before, during, and after this change. Here’s what happens:
  1. The view controller’s view is resized to the new size.

  2. The view controller’s viewWillLayoutSubviews method is called.

  3. The view controller’s view calls its layoutSubviews method.

  4. The view controller’s viewDidLayoutSubviews method is called. 

 
4、 event responder
event
---------->view-->view controller-->super view

5、 Table 8-1  Methods to call to determine why a view’s appearance changed

Method Name

Usage

isMovingFromParent-
ViewController

You call this method inside your viewWillDisappear: and viewDidDisappear: methods to determine if the view controller’s view is being hidden because the view controller was removed from its container view controller.

isMovingToParent-
ViewController

You call this method inside your viewWillAppear: and viewDidAppear: methods to determine if the view controller’s view is being shown because the view controller was just added to a container view controller.

isBeingPresented

You call this method inside your viewWillAppear: and viewDidAppear: methods to determine if the view controller’s view is being shown because the view controller was just presented by another view controller.

isBeingDismissed

You call this method inside your viewWillDisappear: and viewDidDisappear: methods to determine if the view controller’s view is being hidden because the view controller was just dismissed. 


6、if the user cancels the current operation, you can remove all objects in the chain by dismissing the first presented view controller. In other words, dismissing a view controller dismisses not only that view controller but also any view controllers it presented.

If you need to present a view controller programmatically, you must do the following:

  1. Create the view controller you want to present.

  2. Set the modalTransitionStyle property of the view controller to the desired value.

  3. Assign a delegate object to the view controller. Typically, the delegate is the presenting view controller. The delegate is used by the presented view controllers to notify the presenting view controller when it is ready to be dismissed. It may also communicate other information back to the delegate.

  4. Call the presentViewController:animated:completion: method of the current view controller, passing in the view controller you want to present. 

When a view controller is presented, iOS searches for a presentation context. It starts at the presenting view controller by reading its  definesPresentationContext  property. If the value of this property is  YES,  then the presenting view controller defines the presentation context. Otherwise, it continues up through the view controller hierarchy until a view controller returns  YES  or until it reaches the window’s root view controller.

7、 Segue objects are instances of  UIStoryboardSegue  or one of its subclasses.

8、按HOME键后台挂起。。不会触发view load和appear相关的消息,所以界面不需要再次重新生成。。

9.  The first item added to the stack becomes the  root view controller  and is never popped off the stack.

  When  creating  a navigation controller, you must do the following:
  1. Create the root view controller for the navigation interface.

    This object is the top-level view controller in the navigation stack. The navigation bar displays no back button when its view is displayed and the view controller cannot be popped from the navigation stack.

  2. Create the navigation controller, initializing it using the initWithRootViewController: method.

  3. Set the navigation controller as the root view controller of your window (or otherwise present it in your

    interface).
     

When determining whether a view should be sized to fill all or most of the screen, a navigation controller considers several factors, including the following:

Is the underlying window (or parent view) sized to fill the entire screen bounds?
Is the navigation ba
r configured to be translucent ?
Is the navigation toolbar (if used) configured to be translucent?

Is the underlying view controller’s  wantsFullScreenLayout property set to YES ?

If you are creating a navigation interface and want your custom content to span most or all of the screen, here are the steps you should take:

  1. Configure the frame of your custom view to fill the screen bounds.

    Be sure to configure the autoresizing attributes of your view as well. The autoresizing attributes ensure that if your view needs to be resized, it adjusts its content accordingly. Alternatively, when your view is resized, you can call the setNeedsLayout method of your view to indicate that the position of its subviews should be adjusted.

  2. To underlap the navigation bar,set the translucent property of your navigation controller to YES.

  3. To underlap an optional toolbar, set the translucent property of the toolbar to YES.

  4. To underlap the status bar, set the wantsFullScreenLayout property of your view controller to YES. 

When your app launches, you can use the  setViewControllers: animated:  method to restore the navigation controller to a previous state. For example, you would use this method to return the user to the same screen they were viewing when they last quit the app.

To back to more than one level at a time, use the  popToViewController: animated:  method.



You can use the  isMovingToParentViewController  and  isMovingFromParentViewController  methods of  UIViewController  to determine if a view controller is appearing or disappearing as a result of a push or a pop.

The navigation stack and the navigation item stack are always parallel: for each content view controller on the navigation stack, its navigation item is in the same position in the navigation item stack.

For the topmost view controller, the item that is displayed on the left side of the navigation bar is determined using the following rules:

  • If you assign a custom bar button item to the leftBarButtonItem property of the topmost view controller’s navigation item, that item is given the highest preference.
  • If you do not provide a custom bar button item and the navigation item of the view controller one level down on the navigation stack has a valid item in its backBarButtonItem property, the navigation bar displays that item.
  • If a bar button item is not specified by either of the view controllers, a default back button is used and its title is set to the value of the title property of the previous view controller—that is, the view controller one level down on the navigation stack. (If the topmost view controller is the root view controller, no default back button is displayed.)
You should create the items in the  viewDidLoad  method of your view controller.

Using Edit and Done Buttons
myViewController.navigationItem.rightBarButtonItem = [myViewController 
editButtonItem];
If you include this button in your navigation bar, you must also override your view controller’s  setEditing:animated:  method and use it to adjust your view hierarchy.

To configure a toolbar for your navigation interface, you must do the following:

  • Show the toolbar by setting the toolbarHidden property of the navigation controller object to NO.
  • Assign an array of UIBarButtonItem objects to the toolbarItems property of each of your content view controllers, as described in “Specifying the Toolbar Items” (page 30).
  • To hide the toolbar for a specific view controller, set the hidesBottomBarWhenPushed property of that view controller to YES
  • If you want to hide the toolbar sometimes (but not always), you can call the setToolbarHidden:animated: method of the navigation controller at any time.
  • a call to the setNavigationBarHidden:animated: method to create a temporary full-screen view.

10. moreNavigationController   property of   UITabBarController.
The recommended time to create a tab bar item is during the initialization of the view controller itself

If you need to prevent the user from selecting a tab, you can do so by providing a  delegate object  and implementing the  tabBarController:shouldSelectViewController:  method on that object. 

you would not use your tab bar controller delegate to change the appearance of the status bar to match the style of the currently selected view. Visual changes of that nature are best handled by your content view controllers.

Preventing the Customization of Tabs
you can assign an array of view controller objects to the  customizableViewControllers  property.  This array should contain the subset of view controllers that it is all right to rearrange. View controllers not in the array are not displayed on the configuration screen and cannot be removed from the tab bar if they are already there.

Important 
Adding or removing viewcontrollers  in your tab bar interface also resets the array of customizable view controllers to the default value, allowing all view controllers to be customized again.
Therefore, if you make modifications to the  viewControllers  property (either directly or by calling the  setViewControllers:animated:  method) and still want to limit the customizable view controllers, you must also update the array of objects in the  customizableViewControllers  property.

To assign a badge to a tab, assign a non-nil value to the  badgeValue  property  of the corresponding tab bar item.
 if (numberOfNewItems == 0)
{
     self.tabBarItem.badgeValue = nil;
}
else
{
     self.tabBarItem.badgeValue = [NSString stringWithFormat:@"%d", numberOfNewItems];
}

When a device orientation change occurs, the tab bar controller queries its array of view controllers. If any one of them does not support the orientation, the tab bar controller does not change its orientation.

tab bar controller can`t full screen? 

Reproduced in: https: //my.oschina.net/dake/blog/196621

Guess you like

Origin blog.csdn.net/weixin_34085658/article/details/91508777