07 selector Summary

Source: Internet
Author: User

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];

 

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.