Uiviewcontroller is an important part of the iOS program that corresponds to the MVC design pattern C, which manages many views in the program, when the view is loaded, when the view is removed, the rotation of the interface, and so on.
1.UIViewController Create and initialize
[1]. Create and initialize with NIB file
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions {
[2]. Custom creation and initialization
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions {
2.UIViewController Rotation Direction Control
- Before IOS6, the Shouldautorotatetointerfaceorientation method controls the direction of the Uiviewcontroller separately.
-(BOOL) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation { return ( Interfaceorientation = = Uiinterfaceorientationlandscapeleft | | Interfaceorientation = = Uiinterfaceorientationlandscaperight);}
- IOS6 and higher, rewrite this 2 methods, iOS6 inside to rotate there are some areas needing attention, need to add supported interface orientations program support in the Info.plist file.
-(BOOL) shouldautorotate { return YES;} -(Nsuinteger) Supportedinterfaceorientations{return uiinterfaceorientationmaskportrait;//Erect}
3.UIViewController switching
- Uiviewcontroller the call between itself
Uiviewcontroller *test = [[Uiviewcontroller alloc] init];//jump Test[self.window.rootviewcontroller Presentviewcontroller:test animated:yes completion:^{ NSLog (@ "present complete");}];/ /Return to self (test controller disappears) [Self.window.rootViewController Dismissviewcontrolleranimated:yes completion:^{ NSLog (@ "dismiss complete");}];
- Uinavigationcontrolle the controller of the navigation controllers to control the switching between Viewcontrller (hierarchical logical Viewcontrller)
Jump [Self.navigationcontroller pushviewcontroller:test animated:yes]; return to [Self.navigationcontroller Popviewcontrolleranimated:yes];
From the above points can be seen, uiviewcontroller between the switch management, the correct approach is "who pollution who governance."
This site article is for baby bus SD. Team Original, reproduced must be clearly noted: (the author's official website: Baby bus )
Reprinted from "Baby bus Superdo Team" original link: http://www.cnblogs.com/superdo/p/4771718.html
[Objective-c] 019_uiviewcontroller