Uipickerview Basic Use Method

Source: Internet
Author: User

Attention:

1. You need to specify the data source object and the proxy object before using Pickerview.

2. Need to use up to two protocols: Uipickerviewdatasource, Data source protocol, uipickerviewdelegate Proxy Protocol

First, Uipickerview the steps to display the data

1. Lazy Loading of plist files

2. Set the controller to be the current Uipickerview data source object and proxy object

3. Implementing the Data source method Numberofcomponentsinpickerview Returns the number of columns

4. Implement the data source method Pickerview:numberofrowsincomponent Returns the number of rows per column

5. Implement proxy method Pickerview:titleforrow:, returns the data contents of each row

6. Listen for Uipickerview selection events to display the currently selected item on the specified label

Second, the active setting Uipickerview Select an item

Call Uipickerview's selectRow:inComponent:animated: method to set an item to be selected.

Note: When the selectRow:inComponent:animated: method is completed, the system does not actively invoke the Uipickerview proxy-(void) Pickerview: (Uipickerview *) Pickerview Didselectrow: (Nsinteger) Row incomponent: (Nsinteger) component method, so to make the label change, you must call the method manually.

Three, Uipickerview method of reloading

-(void) reloadallcomponents;

-(void) Reloadcomponent: (Nsinteger) component;

The above two methods represent a re-refresh of the data, that is, the data source method and the proxy method are recalled.

Iv. Finally, I would like to add that random numbers are generated

Arc4random ()

C Language Functions

Randomly generates an unsigned integer (0 or all positive integers)

Randomly generates a number between the 0–n

Arc4random ()% (n + 1)

Arc4random_uniform (12)

Uipickerview Basic Use Method

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.