Trailing switch of ios_20_ Weibo dock

Source: Internet
Author: User

Finally: Dock trailing HOMEVC switch together




Requirements:

When you click on a line in the microblog list in Homevc,

Push to Statusdetail Weibo details controller, and the dock disappears together

When you click Statusdetail Weibo details the controller on the left side returns Button,dock also comes back with HOMEVC .


Homevc.m

Click on a microblog in the list to create a statusdetailviewcontroller, assign a value to its member status (data source), and enter the stack by navigation push-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) indexpath{    //Create a microblog body detail controller,    Statusdetailviewcontroller * DETAILVC = [[Statusdetailviewcontroller alloc] init];    Transfer Weibo data (for display) for the microblog body controller that is about to jump    statuslistcellframe *statuslistcellframe = _statuscellframes[indexpath.row] ;    Detailvc.status = Statuslistcellframe.status;    Jump past through the navigation controller    [Self.navigationcontroller PUSHVIEWCONTROLLER:DETAILVC animated:yes];}




As you can see,

The view of the host controller (BEYONDVC) consists of two parts:

1, the upper navigation controller 2, the following dock




The view of the upper navigation Controller also contains two sections:

1, the upper navigation bar (when push, it always does not move)

2, lower root controller (HOMEVC) (animation toggle when push)







In order for the dock and navigation controller root control (HOMEVC) to be able to slide past together, and can slide back together,

The host controller (BEYONDVC) must be the proxy for the navigation controller,

so that it can listen to the push action Willshowviewcontroller and Didshowviewcontroller methods




In the following Willshowviewcontroller methods,

First remove the dock from the host controller (BEYONDVC) and add it to the root control (HOMEVC) of the navigation controller



the proxy method for the navigation controller Willshowviewcontroller


#pragma mark-the proxy method for the navigation controller//Screen width 320#define kwinwidth self.view.bounds.width//screen high 480#define kwinheight self.view.bounds. height//Top State Bar 20#define Kstatusbarheight 20//The purpose is to listen to the push action, when the new controller will enter the top of the stack, set the left button as the return arrow, set the right button to return to the home-(void) Navigationcontroller: (Uinavigationcontroller *) Navigationcontroller Willshowviewcontroller: (UIViewController *) Viewcontroller animated: (BOOL) animated{//Important ~ ~ ~//First get root controller Uiviewcontroller *ROOTVC = NAVIGATIONCONTROLLER.VIEWC        Ontrollers[0]; Assume that the controller to be displayed (which will be pushed into the stack) is not a stack-bottom controller (root controller). Just need to set the left to return button, the right home button if (viewcontroller! = ROOTVC) {//left return to the previous controller Viewcontroller.navig Ationitem.leftbarbuttonitem = [Uibarbuttonitem barbuttonitemwithbgicon:@ "navigationbar_back.png" target:self action                : @selector (POPTOPREVIOUSVC)]; Right back to the home button, that is, back to the stack controller (that is, from the details page back to the list page) ViewController.navigationItem.rightBarButtonItem = [Uibarbuttonitem Barbutton itemwithbgicon:@ "Navigationbar_home.png" target:self action: @selector(BACKTOROOTVC)]; 1, first lengthen the view height of the navigation controller to the height of the entire form-20 (since the dock disappears, the bottom will be more empty black space) NavigationController.view.frame = CGRectMake (0, 20,320,48                0-20);                        2, first remove the dock from the view of the host controller (beyondviewcontroller) [_dock Removefromsuperview]; 3, in order to push the next controller, the dock and the root controller to pan together, so, join the dock to the navigation controller's view of the root controller, and again adjust the dock in the Homevc view of the Y value can be, notice that the navigation will not move, move the navigation root controller, The root Controller's origin (0 0) is: 20+ navigation bar Height 44//Assuming that the root controller is capable of scrolling, it is important to note that the origin of Y is at the top of the tableview (when a certain distance is rolled down) if ([Rootvc.view IsK            Indofclass:[uiscrollview class]] {Uiscrollview * ScrollV = (Uiscrollview *) Rootvc.view; The Y value inside the root controller of the navigation controller of the dock//due to scrolling, the upper left corner of the Rootview to the top of a very far place _dock.frame =cgrectmake (0, Scrollv.contento        Ffset.y + 460-kdockheight, kdockheight); The Y value inside the root controller of the navigation controller of the else {//dock _dock.frame =cgrectmake (0, 480-20-2*kdockheight, +, Kdockheig        HT); }//4, and then add the dock to the navigation controller's root controller (ROOTVC interface (i.e.The root controller of the navigation controller), in order to push the new VC, the dock and the navigation controller's root controller to pan to the left side of the interface, when clicking the return button, the dock will be back with ROOTVC [Rootvc.view addsubview:_dock            ]; }}




in the following in the Didshowviewcontroller method,

First remove the dock from the navigation controller's root control (HOMEVC) and add it to the host controller (BEYONDVC)




the proxy method for the navigation controller Didshowviewcontroller

y = 20 of the navigation controller, height of the navigation controller = total Height-Dock height-20#define kcontentframe cgrectmake (0, Self.view.frame.size.width, Self.view . frame.size.height-kdockheight-20)//BEYONDVC host Controller, the dock y = total height-Dock Height # define Kdockframe cgrectmake (0, Self.view.fra Me.size.height-kdockheight, Self.view.frame.size.width, kdockheight)//The purpose is to monitor the push action and remove the dock from the navigation controller when the new controller is already displayed. Show again to the host controller-(void) Navigationcontroller: (Uinavigationcontroller *) Navigationcontroller Didshowviewcontroller: ( Uiviewcontroller *) Viewcontroller animated: (BOOL) animated{//The root controller of the bottom of the navigation first Uiviewcontroller *ROOTVC = Navigationco    Ntroller.viewcontrollers[0]; Suppose the controller to be displayed is the root controller, and again the dock if (Viewcontroller = = ROOTVC) {//Change the navigation controller view's frame//navigation Controller's y = 20, the height of the navigation controller                = Total Height-Dock height-navigationController.view.frame = kcontentframe;                Remove the dock first from the root controller ROOTVC on the bottom of the stack [_dock Removefromsuperview]; Add the dock to beyondviewcontroller,dock y = total height-Dock height _dock.frame = kdockframe;    [Self.view Addsubview:_dock]; }}




This is achieved, let the main controller inside the dock trailing navigation controller root controller, together disappear, and back together ~


Trailing switch of ios_20_ Weibo dock

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.