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