ios--Select View Uipickerview

Source: Internet
Author: User
Tags current time local time time and date
First, Uipickerview 1. Property1) Data source object

@property (nullable,nonatomic,weak) id<uipickerviewdatasource> DataSource;


2) Proxy Object

@property (Nullable,nonatomic,weak) id<uipickerviewdelegate> delegate;


3) To set whether there is a check mark (with the highlighted background selected)

@property (nonatomic) BOOL showsselectionindicator;


4) Get the number of groups

@property (nonatomic,readonly) Nsinteger numberofcomponents;


5 to get the number of rows in the specified group

-(Nsinteger) Numberofrowsincomponent: (Nsinteger) component;


6 to get the size of each row of the specified group

-(Cgsize) Rowsizeforcomponent: (Nsinteger) component;


7 gets each row view of the specified group, and returns nil if no view is set

-(Nullableuiview *) Viewforrow: (Nsinteger) Row forcomponent: (Nsinteger) component;


8 Reload all the groups

-(void) reloadallcomponents;


9) Reload the specified group

-(void) Reloadcomponent: (Nsinteger) component;


10 set a line directly to display a group, and set the animation effect

-(void) SelectRow: (Nsinteger) Row incomponent: (Nsinteger) component animated: (BOOL) animated;


11 returns the number of rows selected in the specified group and returns-1 if nothing is selected

-(Nsinteger) Selectedrowincomponent: (Nsinteger) component;


2. Uipickerviewdatasource 1 Sets the number of groups in a Uipickerview object (must be implemented)

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


2 Set the number of rows per group (must be implemented)

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

The above two methods must be implemented, that is, when a Uipickerview object is displayed on the screen, the number of groups and rows must be indicated by both methods in order to display a Uipickerview object


3. Uipickerviewdelegate 1) Set the width of each group number

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


2 Set the height of each row of each group

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


3) Set the title of each group, each row

-(Nullablensstring *) Pickerview: (Uipickerview *) Pickerview Titleforrow: (nsinteger) Row forcomponent: (NSInteger) Component


4 set each row of each group view

-(UIView *) Pickerview: (Uipickerview *) Pickerview Viewforrow: (nsinteger) Row forcomponent: (Nsinteger) component Reusingview: (Nullableuiview *) view;


5 A method called by a group or row in the selected

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


Second, Uidatepicker

1. Property

1) Set style; default is Uidatepickermodedateandtime

@property (nonatomic) Uidatepickermode Datepickermode;

typedef ns_enum (Nsinteger, Uidatepickermode) {
    uidatepickermodetime,            //Display time
    uidatepickermodedate,            //Display date
    Uidatepickermodedateandtime,//     display time and date
    Uidatepickermodecountdowntimer,  //show timer
};


2. Set localization properties, default to [Nslocale Currentlocale], and return default if set to nil

@property (Nullable, nonatomic, strong) Nslocale * locale;

Localization attributes encapsulate the level of language and culture, such as date format information;

If you select "China" in the "settings" area of the device, [Nslocale currentlocale].localeinentifier returns @ "ZH_CN"


3. Set calendar properties, default to [Nscalendar Currentcalendar], and return default if set to nil

@property (null_resettable, nonatomic, copy) Nscalendar * calendar;

The default value for this property corresponds to the user's current calendar


4. Set Date property; The default value is the date when the current Uidatepicker object was created

@property (nonatomic, strong) nsdate * DATE;

In Uidatepickermodecountdowntimer mode, the Uipickerview object starts at 0 and ignores this property

This property is the date displayed in the Uipickerview object


5. Set the time zone property, the default value is nil, use the Nstimezone localtimezone (local time zone) as the current time zone, or use the time zone used by the Calendar property as the current time zone

@property (Nullable, nonatomic, Strong) Nstimezone * timeZone;


6. Set the minimum display time; The default is nil,nil means there is no time constraint; when minimumdate > Maximumdate, the value is ignored, and in timer mode, it is ignored.

@property (Nullable, nonatomic, Strong) nsdate * minimumdate;


7. Set the maximum display event; The default is nil.

@property (Nullable, nonatomic, Strong) nsdate * maximumdate;


8. Set the number of seconds to countdown; can only be used in Countdown mode, if it is ignored in other modes; The default is 0, the largest is

23h:59m:59s (86,399s)

@property (nonatomic) Nstimeinterval countdownduration;


9. Set interval time, is to be able to adjust how many seconds; The default is 1, the maximum is 30.

@property (nonatomic) Nsinteger minuteinterval;


10. Set the value of the Date property and set the animation

-(void) Setdate: (NSDate *) Date animated: (BOOL) animated;

Related Article

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.