Implementation of the IOS beginner guide page, source code ., Source code for ios beginners

Source: Internet
Author: User

Implementation of the IOS beginner guide page, source code ., Source code for ios beginners

1/* 1. Find in Main. storyboard, and add ScrollView and PageControl to ViewController. 2. Add ImageView to ScrollView. add several images to the Guide page of the new user, and set the image of the ImageView to the prepared image. 3. set Left in ScrollViewscroll View and Width in View to make it equal to the image size, and the starting position of the image size. The first part is (0, 0 ), the starting position of the second image should be (the screen width, 0), and so on. 4. Add PageControl, and set the start position manually. 5. set synchronization */6 // set UIPageControl to change with UIScrollView 7-(void) scrollViewDidEndDecelerating :( UIScrollView *) scrollView {8 _ pc1.currentPage = scrollView. contentOffset. x/424; 9} 10 // to make UIScrollView change with UIPageControl, you must add a listener and write a method 11-(void) changeScrollView :( UIPageControl *) uip112 {13 [_ sv1 setContentOffset: CGPointMake (424 * uip1.currentPage, 0) animated: YES]; 14} 15 16 Source Code: 17 18 # import "ViewController. h "19 20 @ interface ViewController () 21 @ property (weak, nonatomic) IBOutlet UIScrollView * sv1; 22 @ property (weak, nonatomic) IBOutlet UIPageControl * pc1; 23 24 @ end25 26 @ implementation ViewController27 28-(void) viewDidLoad {29 [super viewDidLoad]; 30 // You must manually set the size of the content view 31 _ sv1.contentSize = CGSizeMake (424*3,736); 32 // whether the page is 33 _ sv1.pagingEnabled = YES; 34 // horizontal scroll bar 35 _ sv1.showsHorizontalScrollIndicator = NO; 36 // vertical scroll bar 37 _ sv1.showsVerticalScrollIndicator = NO; 38 // to set UIPageControl, you need to use the proxy method to determine whether to move 39 _ sv1.delegate = self; 40 // to make UIScrollView change following UIPageControl, you must add a listener and write a Method 41 [_ pc1 addTarget: self action: @ selector (changeScrollView :) forControlEvents: UIControlEventTouchUpInside]; 42} 43 // set UIPageControl to change with UIScrollView 44-(void) unchanged :( UIScrollView *) scrollView {45 _ pc1.currentPage = scrollView. contentOffset. x/424; 46} 47 // to make UIScrollView change with UIPageControl, you must add a listener and write a method 48-(void) changeScrollView :( UIPageControl *) uip149 {50 [_ sv1 setContentOffset: CGPointMake (424 * uip1.currentPage, 0) animated: YES]; 51} 52-(void) didreceivemorywarning {53 [super didreceivemorywarning]; 54 // Dispose of any resources that can be recreated.55} 56 57 @ end

 

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.