Home > Article > Web Front-end > UI development UINavigationController and value transfer between pages_html/css_WEB-ITnose
// Created By Guo Zai April 21, 2015 22:52:59
// =================== ================================
The most painful thing in life is when it’s time to pay the rent! ! ! ! ! ! !
// ============================================ =========
UINavigationController:
Navigation controller is one of the most commonly used multi-view controllers in iOS. It is used to Manage multiple view controllers.
Navigation controller can be considered as a controller that manages controllers, mainly managing hierarchical
controllers.
in a stack way. There must be at least one managed view controller. This controller
us Called the root view controller of the navigation controller.
Any class (polymorphic) that inherits from UIViewController can be used as a root controller.
Working principle:
UINavigationController manages controller switching and controls entry through the stack. Stack and pop
to display each view controller. The view of the top controller on the stack is always displayed in the ContentView of UINavigationController.
The viewControllers attribute stores all managed controllers in the stack
The navigationController attribute is an attribute in the parent class. Each controller in the stack can obtain its own location through this attribute. The UINavigationController object.
pushViewController:animated //进?入下?一个视图控制器
popViewControllerAnimated: //返回上?一个视图控制器
popToViewController:animated //返回到指定的视图控制器Common attributes:
popToRootViewControllerAnimated //返回到根视图控制器
viewControllers //所有处于栈中的控制器
topViewController //位于栈顶的控制器
visibleViewController //当前正在显?示的控制器// =======================
navigationBar //导航条
Jump down:
Jump up:
SecondViewController * secondVC = [[SecondViewController alloc]init]; [self.navigationController pushViewController:secondVC animated:YES];
// [self.navigationController popViewControllerAnimated:YES]; // [self.navigationController popToRootViewControllerAnimated:YES]; SecondViewController * secondVC = [self.navigationController.viewControllers objectAtIndex:0]; [self.navigationController popToViewController:secondVC animated:YES];UINavigationBar:
navigationBar? Navigation bar, iOS7 The default is transparent after that, and the default before iOS7 is opaque
. When the navigationBar is transparent, it will overlap part of the contentView area.
When the navigationBar is opaque, the contentView follows the navigationBar. The default height of navigationBar is 44 in vertical screen and 32 in horizontal screen.
UINavigationItem. Similar to UINavigationController, UINavigationBar also manages a group of UINavigationItems in a stack manner. Provides push and pop operation items.
Every view controller has a navigationItem property. The left button, right button, title, etc. set in navigationItem will be displayed on the navigationBar as the controller is displayed;
//============ =========
UINavigationItem:
UINavigationItem belongs to M in MVC. Encapsulates the data to be displayed on the UINavigationBar
.
UIBarButtonItem belongs to MVC. Defines the triggering events, appearance, etc. of the button on UINavigationItem
-initWithBarButtonSystemItem:target:action:
-initWithTitle:style:target:action: -initWithImage:style:target:action: tintColor;
// =================
// ========
RootViewController * rootVC = [[RootViewController alloc]init]; UINavigationController * nvc = [[UINavigationController alloc]initWithRootViewController:rootVC]; // nvc.navigationBar.backgroundColor = [UIColor redColor]; // nvc.navigationBar.tintColor = [UIColor redColor]; nvc.navigationBar.translucent = YES; nvc.navigationBar.barStyle = UIBarStyleBlack; UIImage * image = [UIImage imageNamed:@"bd_logo1.png"]; [nvc.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
// ===========
UIView * view = [[UIView alloc]init]; view.frame = CGRectMake(0, 200, 20, 20); view.backgroundColor = [UIColor brownColor]; self.navigationItem.title = @"郭仔"; self.navigationItem.titleView = view; [view release]; UIBarButtonItem *btnItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:nil]; self.navigationItem.rightBarButtonItem = btnItem; [btnItem release]; UIImage * img = [[UIImage imageNamed:@"4.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; UIBarButtonItem * leftImage = [[UIBarButtonItem alloc]initWithImage:img style:UIBarButtonItemStyleBordered target:self action:nil]; self.navigationItem.leftBarButtonItem = leftImage;
Page value passing:
One is attribute value passing;
One is to pass value by proxy;
/*
Attribute value passing: If you pass a value from page A to page B, declare the attribute in page B and jump to page A. Assign values to the properties of page B in the event;
Returning to the previous page from the latter page will not execute the loadView and viewDidLoad methods of the previous page, but the viewWillAppear method, because the function of the loadView and viewDidLoad methods is to load the view into Memory, and when returning from the next page, the previous page has been loaded into the memory, so there is no need to load it again, so the loadView and ViewDidLoad methods are not executed;
*/
Proxy value:
Same as the proxy design pattern, just follow the four steps of setting up the proxy and following the protocol. Here is an introduction:
// ===== ==================================
The most enjoyable time of the day is at night Riding on the highway, Hello Beijing-Tibet Expressway~~~~~~~~~