Intermediate Seventh issue: ScrollView common practice

Source: Internet
Author: User


So the younger brother this practice is in Scrllview inside put two tableview, and then through the scrollview of the sliding realization of two tableview, then add two button, to achieve the selected and unchecked, Then the associated button is sliding with the scrollview, and a simple example of changing the state is associated with the sliding button.


This small demo in the actual development will often encounter, so, the small partners can continue to do research and development according to this, continue to add new features, after all, the function of each product is not the same, we need to expand their own


Nonsense not much to say directly on the code

First create a ScrollView, and set its common properties


Uiscrollview *scrollview = [[Uiscrollview alloc] Initwithframe:cgrectmake (0, 0, 360, 444)];    Scrollview.backgroundcolor = [Uicolor Redcolor];    Scrollview.contentsize = Cgsizemake (360 * 2, 0);    scrollview.pagingenabled = YES;    Scrollview.delegate = self;    Self.scrollview = ScrollView; [Self.view Addsubview:scrollview];


Next, create two Tablview and set their common properties


UITableView *lefttableview = [[UITableView alloc] Initwithframe:cgrectmake (0, 0, 444) Style:uitableviewstyleplain]    ;    [Lefttableview Registerclass:[uitableviewcell class] forcellreuseidentifier:leftcellidentify];    Lefttableview.datasource = self;    Lefttableview.delegate = self; [ScrollView Addsubview:lefttableview];


Then get two buttons and set their common properties


UIButton *leftbutton = [UIButton buttonwithtype:uibuttontypecustom];    Leftbutton.frame = CGRectMake (120, 500, 50, 50);    [LeftButton settitle:@ "left" forstate:uicontrolstatenormal];    Leftbutton.backgroundcolor = [Uicolor Bluecolor]; [LeftButton addtarget:self Action: @selector (Changeleftactionbutton:) forcontrolevents:uicontroleventtouchupinside    ]; [Self.view Addsubview:leftbutton];


How to associate a button


-(void) Changerightactionbutton: (UIButton *) button {[UIView animatewithduration:0.3 animations:^{[Self.scrollvi    EW Setcontentoffset:cgpointmake (360, 0)]; }];}


The delegate method of association ScrollView


-(void) Scrollviewdidscroll: (Uiscrollview *) ScrollView {}


Well, just write it here, it is only printed a way, as for the subsequent implementation and relevance, but also the small partners to operate their own implementation oh, come on


This article is from the "Neusoft iOS Alumni Group Technology Blog" blog, please be sure to keep this source http://neusoftios.blog.51cto.com/9977509/1638693

Intermediate Seventh issue: ScrollView common practice

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.