Iosapp Beginner's Guide

Source: Internet
Author: User

Tag:ios    source     novice boot    

1. Found in Main.storyboard, ScrollView and Pagecontrol. 2. Add ImageView in ScrollView, the Novice guide page has several pictures to add several, and then set the image of ImageView, is ready for the picture. 3. To set the width in the left and view in the Scrollviewscroll view, so that it is equal to the size of the picture, and the starting position of the image size, the first is (0,0), the starting position of the second sheet should be (screen width, 0), and so on. 4. Add Pagecontrol, the starting position of this to be set manually. 5. Set sync//settings Uipagecontrol follow Uiscrollview change-(void) scrollviewdidenddecelerating: (uiscrollview *) ScrollView {    _pc1.currentpage = scrollview.contentoffset.x / 424;} To make Uiscrollview follow Uipagecontrol change, you must listen, to write a method-(void) Changescrollview: (uipagecontrol *) uip1{      [_sv1 setcontentoffset:cgpointmake (424 * uip1.currentpage, 0)  animated:yes];} Source: #import   "ViewController.h" @interface  ViewController  () @property   (weak, nonatomic)  IBOutlet UIScrollView *sv1; @property   (weak, nonatomic)  IBOutlet  uipagecontrol *pc1; @end @implementation viewcontroller-  (void) viewdidload {    [super viewdidload];    //You must manually set the size of the content view      _sv1.contentsize = cgsizemake (424*3,736);     //whether paging      _sv1.pagingenabled = yes;    //whether the horizontal scroll bar is displayed when scrolling     _ sv1.showshorizontalscrollindicator = no;    //whether to display a vertical scroll bar when scrolling      _sv1.showsverticalscrollindicator=no;    //to set Uipagecontrol, use proxy method to determine whether to move      _sv1.delegate = self;    //to make Uiscrollview follow Uipagecontrol change, Must be listening, to write a method     [_pc1 addtarget:self action: @selector (changescrollview:)   Forcontrolevents: uicontroleventtouchupinside];} Set Uipagecontrol to follow Uiscrollview change-(void) scrollviewdidenddecelerating: (uiscrollview *) scrollview{     _pc1.currentpage = scrollview.contentoffset.x / 424;} //To make Uiscrollview follow Uipagecontrol change, you must listen, to write a method-(void) Changescrollview: (uipagecontrol *) uip1{      [_sv1 setcontentoffset:cgpointmake (424 * uip1.currentpage, 0)   Animated:yes];} -  (void) didreceivememorywarning {    [super didreceivememorywarning];     // dispose of any resources that can be recreated.} @end


This article is from the "Red Corner Antelope" blog, please be sure to keep this source http://2254359459.blog.51cto.com/10776102/1733929

Iosapp Beginner's Guide

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.