07选取器总结


选取器载入图像时要包装成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:时间];

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值