Guest User

Untitled

a guest
Jul 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.10 KB | None | 0 0
  1. //
  2. // UIViewController.h
  3. // UIKit
  4. //
  5. // Copyright 2007-2009 Apple Inc. All rights reserved.
  6. //
  7.  
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKitDefines.h>
  10. #import <UIKit/UIApplication.h>
  11.  
  12. /*!
  13. UIViewController is a generic controller base class that manages a view.
  14. It has methods that are called when a view appears or disappears.
  15.  
  16. Subclasses can override -loadView to create their custom view hierarchy, or specify a nib name to be loaded automatically.
  17. This class is also a good place for delegate & datasource methods, and other controller stuff.
  18. */
  19.  
  20. @class UIView, UIImage;
  21. @class UINavigationItem, UIBarButtonItem, UITabBarItem;
  22. @class UITabBarController, UINavigationController, UISearchDisplayController;
  23. @class NSHashTable;
  24.  
  25. typedef enum {
  26. UIModalTransitionStyleCoverVertical = 0,
  27. UIModalTransitionStyleFlipHorizontal,
  28. UIModalTransitionStyleCrossDissolve
  29. } UIModalTransitionStyle;
  30.  
  31. UIKIT_EXTERN_CLASS @interface UIViewController : UIResponder <NSCoding> {
  32. @package
  33. UIView *_view;
  34. UITabBarItem *_tabBarItem;
  35. UINavigationItem *_navigationItem;
  36. NSArray *_toolbarItems;
  37. NSString *_title;
  38.  
  39. NSString *_nibName;
  40. NSBundle *_nibBundle;
  41.  
  42. UIViewController *_parentViewController; // Nonretained
  43. NSHashTable *_childViewControllers; // Nonretained
  44.  
  45. UIViewController *_childModalViewController;
  46. UIView *_modalTransitionView;
  47. UIResponder *_modalPreservedFirstResponder;
  48. UIView *_dimmingView;
  49. UIView *_presentationSuperview;
  50. id _currentAction;
  51.  
  52. UIView *_savedHeaderSuperview;
  53. UIView *_savedFooterSuperview;
  54.  
  55. UIBarButtonItem *_editButtonItem;
  56.  
  57. UISearchDisplayController *_searchDisplayController;
  58.  
  59. UIModalTransitionStyle _modalTransitionStyle;
  60.  
  61. UIInterfaceOrientation _lastKnownInterfaceOrientation;
  62.  
  63. struct {
  64. unsigned int appearState:2;
  65. unsigned int isEditing:1;
  66. unsigned int isPerformingModalTransition:1;
  67. unsigned int hidesBottomBarWhenPushed:1;
  68. unsigned int autoresizesArchivedViewToFullSize:1;
  69. unsigned int viewLoadedFromControllerNib:1;
  70. unsigned int isRootViewController:1;
  71. unsigned int isSuspended:1;
  72. unsigned int wasApplicationFrameAtSuspend:1;
  73. unsigned int wantsFullScreenLayout:1;
  74. unsigned int shouldUseFullScreenLayout:1;
  75. unsigned int allowsAutorotation:1;
  76. unsigned int searchControllerRetained:1;
  77. } _viewControllerFlags;
  78. }
  79.  
  80. // The designated initializer. If you subclass UIViewController, you must call the super implementation of this method, even if you aren't using a NIB.
  81. // 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.
  82. // If you pass in a nil nib name, then you must either call -setView: before -view is invoked, or override -loadView to set up your views.
  83. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
  84.  
  85. @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.
  86. - (void)loadView; // This is where subclasses should create their custom view hierarchy if they aren't using a nib. Should never be called directly.
  87. - (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.
  88. - (void)viewDidUnload __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_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.
  89. - (BOOL)isViewLoaded __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
  90.  
  91. @property(nonatomic, readonly, copy) NSString *nibName; // The name of the nib to be loaded to instantiate the view.
  92. @property(nonatomic, readonly, retain) NSBundle *nibBundle; // The bundle from which to load the nib.
  93.  
  94. - (void)viewWillAppear:(BOOL)animated; // Called when the view is about to made visible. Default does nothing
  95. - (void)viewDidAppear:(BOOL)animated; // Called when the view has been fully transitioned onto the screen. Default does nothing
  96. - (void)viewWillDisappear:(BOOL)animated; // Called when the view is dismissed, covered or otherwise hidden. Default does nothing
  97. - (void)viewDidDisappear:(BOOL)animated; // Called after the view was dismissed, covered or otherwise hidden. Default does nothing
  98.  
  99. @property(nonatomic,copy) NSString *title; // Localized title for use by a parent controller.
  100.  
  101. - (void)didReceiveMemoryWarning; // Called when the parent application receives a memory warning. Default implementation releases the view if it doesn't have a superview.
  102.  
  103. - (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated; // Display another view controller as a modal child. Uses a vertical sheet transition if animated.
  104. - (void)dismissModalViewControllerAnimated:(BOOL)animated; // Dismiss the current modal child. Uses a vertical sheet transition if animated.
  105. @property(nonatomic,readonly) UIViewController *modalViewController;
  106.  
  107. // 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.
  108. // Defaults to UIModalTransitionStyleSlideVertical.
  109. @property(nonatomic,assign) UIModalTransitionStyle modalTransitionStyle __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
  110.  
  111. @property(nonatomic,assign) BOOL wantsFullScreenLayout __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
  112.  
  113. @property(nonatomic,readonly) UIViewController *parentViewController; // If this view controller is inside a navigation controller or tab bar controller, or has been presented modally by another view controller, return it.
  114.  
  115. @end
  116.  
  117. // To make it more convenient for applications to adopt rotation, a view controller may implement the below methods.
  118. // Your UIWindow's frame should use [UIScreen mainScreen].bounds as its frame.
  119. @interface UIViewController (UIViewControllerRotation)
  120.  
  121. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation; // Override to allow rotation. Default returns YES only for UIDeviceOrientationPortrait
  122.  
  123. // The rotating header and footer views will slide out during the rotation and back in once it has completed.
  124. - (UIView *)rotatingHeaderView; // Must be in the view hierarchy. Default returns nil.
  125. - (UIView *)rotatingFooterView; // Must be in the view hierarchy. Default returns the active keyboard.
  126.  
  127. @property(nonatomic,readonly) UIInterfaceOrientation interfaceOrientation;
  128.  
  129. // Notifies when rotation begins, reaches halfway point and ends.
  130. - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
  131. - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;
  132.  
  133. // Faster one-part variant, called from within a rotating animation block, for additional animations during rotation.
  134. // A subclass may override this method, or the two-part variants below, but not both.
  135. - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
  136.  
  137. // Slower two-part variant, called from within a rotating animation block, for additional animations during rotation.
  138. // A subclass may override these methods, or the one-part variant above, but not both.
  139. - (void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
  140. - (void)didAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation; // The rotating header and footer views are offscreen.
  141. - (void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)duration; // A this point, our view orientation is set to the new orientation.
  142.  
  143. @end
  144.  
  145. // Many view controllers have a view that may be in an editing state or not- for example, a UITableView.
  146. // These view controllers can track the editing state, and generate an Edit|Done button to be used in a navigation bar.
  147. @interface UIViewController (UIViewControllerEditing)
  148.  
  149. @property(nonatomic,getter=isEditing) BOOL editing;
  150. - (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.
  151.  
  152. - (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.
  153.  
  154. @end
  155.  
  156. @interface UIViewController (UISearchDisplayControllerSupport)
  157.  
  158. @property(nonatomic, readonly, retain) UISearchDisplayController *searchDisplayController;
  159.  
  160. @end
Add Comment
Please, Sign In to add comment