Blink of an eye, another day, just so busy day of the day, but fortunately, not a muddle, but also a small to become, Labor has won it, hey!
Well, to the summary of the time, the following for everyone to explain the contents of my study today, I hope that you have some help it, but also a kind of encouragement for themselves, and finally achieve a total win bar hey!
First of all, in class time we first briefly described Uiscrollview, it is a scrolling view, inherited from UIView, he did not own initialization method, so to use the parent class to create a method below for everyone to simply explain its creation process ha:
Uiscrollview *scrollview =[[Uiscrollview alloc] initWithFrame:self.view.bounds]; Scrollview.backgroundcolor=[Uicolor Redcolor]; //sets the size of the content page, which must be larger than frame to scroll//if the size of the content page is not set, the default and frame size are the same[ScrollView Setcontentsize:cgsizemake ( the,568*3)]; //sets whether the scroll bar is visible//Horizontal scroll barScrollview.showshorizontalscrollindicator =YES; //Vertical scroll barScrollview.showsverticalscrollindicator =YES; //sets the offset of the content page, starting with the default content page (0, 0) .Scrollview.contentoffset = Cgpointmake (0,0); //set the entire page slidescrollview.pagingenabled =NO; //sets whether the boundary bounces backScrollview.bounces =YES; //Scroll to topScrollview.scrollstotop =YES; //Set whether scrolling is possiblescrollview.scrollenabled =YES; //sets whether the bounds bounce, only if the content width or height is less than the width or height of the frameScrollview.alwaysbouncevertical =YES; Scrollview.alwaysbouncehorizontal=YES; //Scaling , scaling must be combined with proxy (delegate) to take effect, specifying which view on the ScrollView to scale//sets the current zoom ratio, which defaults to 1.0Scrollview.zoomscale =1.0; //Set maximum zoom ratioScrollview.maximumzoomscale =2.0; //set minimum zoom ratioScrollview.minimumzoomscale =0.5; //Set DelegateScrollView.Delegate=Self ; [Self.view Addsubview:scrollview]; [ScrollView release]; ImageView= [[Uiimageview alloc] initwithimage:[uiimage imagenamed:@"Image"]]; Imageview.frame= CGRectMake (0,0, the,568*3); [ScrollView Addsubview:imageview]; [ImageView release];
The common methods of delegate agents are as follows:
- (void) didreceivememorywarning{[Super didreceivememorywarning]; //Dispose of any resources the can be recreated.}//called when scrolling scrollview- (void) Scrollviewdidscroll: (Uiscrollview *) scrollview{NSLog (@"%s", __function__);}//called when scaling is occurring- (void) Scrollviewdidzoom: (Uiscrollview *) scrollview{NSLog (@"%s", __function__);}//which view in ScrollView is scaled-(UIView *) Viewforzoominginscrollview: (Uiscrollview *) scrollview{returnImageView;}//call when you're about to start dragging- (void) Scrollviewwillbegindragging: (Uiscrollview *) scrollview{NSLog (@"%s", __function__);}//called when the drag is going to end- (void) Scrollviewwillenddragging: (Uiscrollview *) ScrollView withvelocity: (cgpoint) Velocity targetcontentoffset: (inout Cgpoint *) targetcontentoffset{NSLog (@"%s", __function__);}//called when the drag has ended- (void) Scrollviewdidenddragging: (Uiscrollview *) ScrollView willdecelerate: (BOOL) decelerate{NSLog (@"%s", __function__);}
Feel Uiscrollview is for the next to make a cushion, in order to achieve after the image page number of the switch and scrolling
And then we talked about Uipagecontrol.
Uipagecontrol: Page number controller, inheritance and Uicontrol
He, like Uiscrollview, does not have his own method of initialization, but also uses the method of his own parent class, which is created as follows
- (void) viewdidload{[Super Viewdidload]; //Uipagecontrol: Page number controller, inherited from UicontrolUipagecontrol *pagecontrol =[[Uipagecontrol alloc] init]; Pagecontrol.frame= CGRectMake (0, -, the, -); Pagecontrol.backgroundcolor=[Uicolor Blackcolor]; Pagecontrol.numberofpages=Ten; //Set Unselected colorsPagecontrol.pageindicatortintcolor =[Uicolor Yellowcolor]; //Set the selected colorPagecontrol.currentpageindicatortintcolor =[Uicolor Bluecolor]; //Hide when setting only one pagePagecontrol.hidesforsinglepage =NO; //Correlation Method[Pagecontrol addtarget:self Action: @selector (changepage:) forcontrolevents:uicontroleventvaluechanged]; [Self.view Addsubview:pagecontrol]; [Pagecontrol release];}- (void) didreceivememorywarning{[Super didreceivememorywarning]; //Dispose of any resources the can be recreated.}- (void) Changepage: (Uipagecontrol *) pagecontrol{//the page number is zero- basedNSLog (@"%d", Pagecontrol.currentpage +1);}
Let's go through an exercise to further understand these spaces:
Through the page scrolling and the page number of the switch to invoke the method so that the effect is similar to the way we look at the ebook page jump, below I will attach the code for your reference:
- (void) Changepage: (Uipagecontrol *) pagecontrol{if(Pagecontrol.currentpage = =0) {[ScrollView1 Setcontentoffset:cgpointmake (0,0) Animated:yes]; } Else if(Pagecontrol.currentpage = =1) {[ScrollView1 Setcontentoffset:cgpointmake ( the,0) Animated:yes]; } Else if(Pagecontrol.currentpage = =2) {[ScrollView1 Setcontentoffset:cgpointmake ( the*2,0) Animated:yes]; }}- (void) Scrollviewdidenddecelerating: (Uiscrollview *) scrollview{Pagecontrol1.currentpage= Scrollview.contentoffset.x/ the;}- (void) Close: (UIButton *) button1{//if the parent view of the child view is removed, the child view is also removed[Button Removefromsuperview]; [ScrollView1 Removefromsuperview]; [PageControl1 Removefromsuperview];}
Where-(void) Close: (UIButton *) Button1 This method is used to jump to the homepage, just as we will show some new features when we open an app
-(void) Changepage: (Uipagecontrol *) Pagecontrol This method is used to make a page change using the paging slot and then when these are done we only need to introduce the file's. m file to the controller. That is Uiviewcontroller, the following for everyone to attach effect animation diagram:
These are what we learn today, gradually found that they are also slowly interested in these small things, but also began to like to delve into some new things, although the 0 basis, but I believe that as long as the effort, nothing is impossible, perhaps just at the beginning you do not even know the code is what, but these are not important, It is important to win not arrogant defeated hungry, know how to work hard, knowing that the struggle is the most important, talent is important, but only the talent but do not know the treasure that is equal to the useless, so tell me here and I like to program interested friends, do not be afraid, do what you want to do, as long as the direction of the right, Then we're going to pay for the effort and action, hey, everybody, byebye!.
Ios:ui series of Uiscrollview and Uipagecontrol