選取器載入映像時要封裝成UIImageView
UIPickerViewDataSource,UIPickerViewDelegate
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView* )pickerView;
-(NSInteger)pickerView:(UIPickerView*)pickerView numberOfRowsInComponent:(NSInteger)component;
(required)選取器中的元素
//字串 -(NSString*)pickerView:(UIPickerView*)pickerView
titleForRow:(NSInteger)row
forComponent:(NSInteger)component;
//映像 -(UIView*)pickerView:(UIPickerView*)pickerView
viewForRow:(NSInteger)row
forComponent:(NSInteger)component;
當選取器有兩個組件(即有兩個框)且右邊框的內容隨左邊框的內容變換而變換時,實現
-(void)pickerView:(UIPickerView*)pickerView
didSelectRow:(NSInteger)row
inComponent:(NSInteger)component;
如果要調整兩個組件的大小則
-(CGFloat)pickerView:(UIPickerView*)pickerView widthForComponent:(NSInteger)component;
注意:IB中需配置pickerView的attribute 中的dataSource與Delegate都連向File's Owner
UIPickerView 方法:-(NSInteger)selectedRowInComponent:(int);
尋找路徑並載入
NSBundle *bundle=[NSBundle mainBundle];
NSString *path=[bundle pathForResource:@"檔案名稱" ofType:@"副檔名"];
NSDictionary *d=[[NSDictionary alloc]initWithContentsOfFile:path];
排序數組
NSArray *array;
NSArray *sorted=[array sortedArrayUsingSelector:@selector(compare:)];
得到字典的全部鍵
NSArray *arr=[dictionary allKeys];
選擇選取器的特定組件特定行並實現動畫
[picker selectedRow:row inComponent:component animated:YES];
[picker reloadComponent:component];
映像匯入
UIImage *image=[UIImage imageName:@"全部檔案名稱"];
UIImageView *imageView=[[UIImageView alloc]initWithName:image];
索引值對
[self setValue:NSObject* forKey:@"..."];
隨機數產生
int i=random()%n;
視頻音頻匯入
#import<AudioToolbox/AudioToobox.h>
第一:記得加入framework
NSString *path=[[NSBundle mainBundle]pathForResource:@"檔案名稱" ofType:@"副檔名"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileWithPath:path],&soundID);
AudioServicesPlaySystemSound(soundID);
自訂調用方法函數
[self performSelector:@selector(函數名) withObject:nil afterDelay:時間];