Easy and Practical IOS Uipickerview

Source: Internet
Author: User

In fact, Uipickerview and uitableview implementation methods, roughly the same, even the role is the same, just use in a different effect only, then the following records a few methods can achieve Uipickerview effect:

1. Set the Uipickerview column

-(Nsinteger) Numberofcomponentsinpickerview: (Uipickerview *) Pickerview;

2, set the line of Uipickerview

-(Nsinteger) Pickerview: (Uipickerview *) Pickerview numberofrowsincomponent: (nsinteger) component;

3, set the line height of Uipickerview

-(CGFloat) Pickerview: (Uipickerview *) Pickerview rowheightforcomponent: (nsinteger) component;

4, set the text information of Uipickerview

-(NSString *) Pickerview: (Uipickerview *) Pickerview Titleforrow: (nsinteger) Row forcomponent: (Nsinteger) component;

5. Uipickerview Click events

-(void) Pickerview: (Uipickerview *) Pickerview Didselectrow: (nsinteger) Row incomponent: (Nsinteger) component;

      with the 5 steps above, you can achieve a scrolling effect. However, here is a problem, is not like UITableView in the cell method to set [morecell. textlabel setfont :[ Uifont systemfontofsize : 15.0f ]]; Style or font size, this involves another implementation in Uipickerview:

-(UIView *) Pickerview: (Uipickerview *) Pickerview Viewforrow: (nsinteger) Row forcomponent: (Nsinteger) component Reusingview: (UIView *) view{       UILabel *laltitle= (UILabel *) view;    if (!laltitle) {        Laltitle=[[uilabel alloc] init];        laltitle.minimumscalefactor=8;//sets the minimum font, which is the same as minimumfontsize, minimumfontsize cannot be used after iOS 6.        laltitle.adjustsfontsizetofitwidth=yes;//Sets whether the font size fits Lalbel width        laltitle.textalignment= nstextalignmentcenter;//Text Center display        [Laltitle settextcolor:[uicolor blackcolor];        [Laltitle Setfont:[uifont systemfontofsize:17.0f];    }    Laltitle.text=[self Pickerview:pickerview Titleforrow:row forcomponent:component];    return laltitle;   }

  

To this, Uipickerview's simple and practical realization!!!!

Easy and Practical IOS Uipickerview

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.