Tile navigation-based on the implementation of split-screen navigation (iOS development)

Source: Internet
Author: User
Tags uikit

Navigation mode

-Tile Navigation: Content does not have hierarchical relationship, in fact, on a main screen, just using a split-screen paging controller to navigate, you can swipe up and down the screen to view content. (such as: The system comes with the weather)

-Tag navigation: content is divided into several function modules, but these features actually have no relationship. Manage with tags. There are too many tags to apply ...

-Tree navigation: Hierarchical, top-to-bottom subdivision for or inclusive relationships. (such as: mailbox)


These few are often combined together to use.

This is mainly about tiled navigation.

The control used is a split-screen control (Uipagecontrol) and a scrolling view control (ScrollView), in which we may indeed create a new view controller for many view controllers, but do not actually belong to any subclasses. Just to get a few pictures of us somewhere to place.

The need to understand here is that the app has only one view, this view contains a scrollview, and this scrollview has several screens so large, each screen a picture. We move around as if there were many view, but the real scrollview is the huge one.




#import <UIKit/UIKit.h> @interface viewcontroller:uiviewcontroller<uiscrollviewaccessibilitydelegate> @property (Strong, nonatomic) UIView *page1; @property (Strong, nonatomic) UIView *page2; @property (Strong, nonatomic) UIV Iew *page3; @property (weak, nonatomic) Iboutlet Uiscrollview *scrollview; @property (weak, nonatomic) Iboutlet Uipagecontrol *pagecontrol;-(ibaction) Changepage: (ID) sender; @end

#import "ViewController.h" @interface Viewcontroller () @end @implementation viewcontroller-(void) viewdidload {[Super V        Iewdidload];    Self.scrollView.contentSize = Cgsizemake (self.view.frame.size.width*3, self.scrollView.frame.size.height);        Self.scrollView.frame = Self.view.frame;    New SB's Reference Uistoryboard *mainstoryboard = [Uistoryboard storyboardwithname:@ "Main" bundle:nil]; The following piece of code is in order to get the Viewcontroller//Page1.page2.page3 of the file name in the project is not even hot in H, because from this point of view they are more like attributes//contentsize is the content size, and fr    AME is the window size uiviewcontroller* page1viewcontroller = [Mainstoryboard instantiateviewcontrollerwithidentifier:@ "Page1"];    Self.page1 = Page1viewcontroller.view;            Self.page1.frame = CGRectMake (0.0f, 0.0f, 320.0f, 420.0f);    uiviewcontroller* Page2viewcontroller = [Mainstoryboard instantiateviewcontrollerwithidentifier:@ "Page2"];    Self.page2 = Page2viewcontroller.view;        Self.page2.frame = CGRectMake (320.0f, 0.0f, 320.0f, 420.0f); uiviewcontroller* Page3Viewcontroller = [Mainstoryboard instantiateviewcontrollerwithidentifier:@ "Page3"];    Self.page3 = Page3viewcontroller.view;        Self.page3.frame = CGRectMake (2 * 320.0f, 0.0f, 320.0f, 420.0f);        Need to implement Uiscrollviewdelegate protocol self.scrollView.delegate = self;    [Self.scrollview AddSubview:self.page1];    [Self.scrollview AddSubview:self.page2]; [Self.scrollview AddSubview:self.page3];}    -(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} After each screen, you need to calculate and set the current screen currentpage-(void) Scrollviewdidscroll: (Uiscrollview *) ascrollview{//offset for content size Cgpoint    offset = Ascrollview.contentoffset; Self.pageControl.currentPage = offset.x/320.0f; Returns the current page}//this is to produce an animated effect-(ibaction) Changepage: (ID) Sender {[UIView animatewithduration:0.3f animations:^{int        Whichpage = Self.pageControl.currentPage;    Self.scrollView.contentOffset = Cgpointmake (320.0f*whichpage, 0.0f); }];} @end


Tile navigation-based on the implementation of split-screen navigation (iOS development)

Related Article

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.