When the selector loads an image, it needs to be packaged into a uiimageview.
Uipickerviewdatasource, uipickerviewdelegate
-(Nsinteger) numberofcomponentsinpickerview :( uipickerview *) pickerview;
-(Nsinteger) pickerview :( uipickerview *) pickerview numberofrowsincomponent :( nsinteger) component;
(Required) elements in the selector
// String-(nsstring *) pickerview :( uipickerview *) pickerview
Titleforrow :( nsinteger) Row
Forcomponent :( nsinteger) component;
// Image-(uiview *) pickerview :( uipickerview *) pickerview
Viewforrow :( nsinteger) Row
Forcomponent :( nsinteger) component;
When the selector has two components (that is, two boxes) and the content of the right border changes with the content of the left border
-(Void) pickerview :( uipickerview *) pickerview
Didselectrow :( nsinteger) Row
Incomponent :( nsinteger) component;
If you want to adjust the size of the two components
-(Cgfloat) pickerview :( uipickerview *) pickerview widthforcomponent :( nsinteger) component;
Note: In IB, you must configure datasource and delegate in the attributes of pickerview to be connected to the file's owner.
Uipickerview method:-(nsinteger) selectedrowincomponent :( INT );
Search for paths and Load
Nsbundle * bundle = [nsbundle mainbundle];
Nsstring * Path = [bundle pathforresource: @ "file name" oftype: @ "extension"];
Nsdictionary * D = [[nsdictionary alloc] initwithcontentsoffile: path];
Sort Array
Nsarray * array;
Nsarray * sorted = [array sortedarrayusingselector: @ selector (compare :)];
Obtain all keys of the dictionary.
Nsarray * arr = [dictionary allkeys];
Select a specific component line of the selector and implement animation
[Picker selectedrow: Row incomponent: component animated: Yes];
[Picker reloadcomponent: component];
Image Import
Uiimage * image = [uiimage imagename: @ "all file names"];
Uiimageview * imageview = [[uiimageview alloc] initwithname: Image];
Key-value pairs
[Self setvalue: nsobject * forkey: @ "..."];
Random Number Generation
Int I = random () % N;
Video and audio Import
# Import <audiotoolbox/audiotoobox. h>
First, remember to add the framework
Nsstring * Path = [[nsbundle mainbundle] pathforresource: @ "file name" oftype: @ "extension"];
Systemsoundid soundid;
Audioservicescreatesystemsoundid (cfurlref) [nsurl filewithpath: path], & soundid );
Audioservicesplaysystemsound (soundid );
Custom call methods and functions
[Self defined mselector: @ selector (function name) withobject: Nil afterdelay: Time];