iOS Development UI Foundation Uipikerview Properties

Source: Internet
Author: User

Properties of the Uipikerview


1. Numberofcomponents: Returns the current number of columns in Uipickerview
Nsinteger num = _pickerview.numberofcomponents;
NSLog (@ "%d", num);


2.-(Nsinteger) Numberofrowsincomponent: (Nsinteger) component; Returns how many rows are in the component column.
Nsinteger NUMINCP = [_pickerview numberofrowsincomponent:0];
NSLog (@ "%d", NUMINCP);


3.-(Cgsize) Rowsizeforcomponent: (Nsinteger) component; Returns the size of a row in component.

Cgsize size = [_pickerview rowsizeforcomponent:0];
NSLog (@ "%@", nsstringfromcgsize (size));


Delegate:
2.0 setting up the Uipickerview agent
_pickerview.delegate = self;
Set the contents of Uipickview per row
2.1-(NSString *) Pickerview: (Uipickerview *) Pickerview Titleforrow: (nsinteger) Row forcomponent: (Nsinteger) component
{
return @ "ShowData";
}


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

Returns a view that sets the content displayed for each row of the Pickerview.
-(UIView *) Pickerview: (Uipickerview *) Pickerview Viewforrow: (nsinteger) Row forcomponent: (Nsinteger) component Reusingview: (UIView *) view
{
UIView *myview=[[uiview Alloc]init];
Myview.backgroundcolor = [Uicolor Redcolor];
return myView;
}


DataSource: Data source
#pragma Mark-datasource method
Set each column to show 3 rows
-(Nsinteger) Pickerview: (Uipickerview *) Pickerview numberofrowsincomponent: (Nsinteger) component
{
return 3;
}
Set Display 2 columns
-(Nsinteger) Numberofcomponentsinpickerview: (Uipickerview *) Pickerview
{
return 2;
}


4. Showsselectionindicator: Whether the indicator is displayed, the default is no
_pickerview.showsselectionindicator = NO;

Note: Setting the number of rows and columns of Uipickerview requires setting up the data source, complying with Uipickerviewdatasource, setting the Uipickerview content, and complying with the proxy method uipickerviewdelegate.


5.-(void) Pickerview: (uipickerview*) Pickerview Didselectrow: (nsinteger) Row incomponent: (Nsinteger) component;
This method is called when a row in a column of Uipickerview is clicked.


6. Return the height of each row in column component
-(CGFloat) Pickerview: (Uipickerview *) Pickerview
Rowheightforcomponent: (Nsinteger) component;

7. Refresh data for a column
Once this method is called, a message is sent back to the data source to calculate the number of rows in the column and to send the message back to the agent to get the contents of this column.
[Pickerview reloadcomponent:1];


8. Refresh data for all columns
-(void) reloadallcomponents;


9. Return to the first row of column component.
-(Nsinteger) Selectedrowincomponent: (Nsinteger) component;



iOS Development UI Foundation Uipikerview Properties

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.