07 Picker Summary

Source: Internet
Author: User


When the picker loads the image, it wraps it into a uiimageview
Uipickerviewdatasource,uipickerviewdelegate
-(Nsinteger) Numberofcomponentsinpickerview: (uipickerview*) Pickerview;
-(Nsinteger) Pickerview: (uipickerview*) Pickerview numberofrowsincomponent: (nsinteger) component;

(required) elements in the picker
String-(nsstring*) Pickerview: (uipickerview*) Pickerview
Titleforrow: (Nsinteger) row
Forcomponent: (Nsinteger) component;

Image-(uiview*) Pickerview: (uipickerview*) Pickerview
Viewforrow: (Nsinteger) row
Forcomponent: (Nsinteger) component;
When the picker has two components (that is, there are two boxes) and the contents of the right border are transformed with the contents of the left border, the implementation
-(void) Pickerview: (uipickerview*) Pickerview
Didselectrow: (Nsinteger) row
Incomponent: (Nsinteger) component;
If you want to resize a two component,
-(CGFloat) Pickerview: (uipickerview*) Pickerview widthforcomponent: (nsinteger) component;

Note: The DataSource and delegate in the attribute that are required to configure Pickerview in IB are connected to file's Owner

Uipickerview method:-(Nsinteger) selectedrowincomponent: (int);
Find the path and load it in
NSBundle *bundle=[nsbundle Mainbundle];
NSString *path=[bundle pathforresource:@ "file name" oftype:@ "extension"];
Nsdictionary *d=[[nsdictionary Alloc]initwithcontentsoffile:path];

Sort arrays
Nsarray *array;
Nsarray *sorted=[array sortedarrayusingselector: @selector (compare:)];

Get all the keys to the dictionary
Nsarray *arr=[dictionary AllKeys];

Select specific component-specific lines for the picker and animate them
[Picker Selectedrow:row incomponent:component Animated:yes];
[Picker reloadcomponent:component];

Image Import
UIImage *image=[uiimage imagename:@ "all filenames"];
Uiimageview *imageview=[[uiimageview Alloc]initwithname:image];

Key-value pairs
[Self setvalue:nsobject* forkey:@ "..."];

Random number generation
int i=random ()%n;

Video Audio Import
#import <AudioToolbox/AudioToobox.h>
First: Remember to join the framework
NSString *path=[[nsbundle mainbundle]pathforresource:@ "file name" oftype:@ "extension"];
Systemsoundid Soundid;
Audioservicescreatesystemsoundid ((cfurlref) [Nsurl Filewithpath:path],&soundid);
Audioservicesplaysystemsound (Soundid);

Custom Call Method functions
[Self performselector: @selector (name of function) 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.