UIPickView用法

//初始化: 
 TimesPickerView = [[UIPickerView alloc] initWithFrame:CGRectZero]
 CGRect pickerRect = CGRectMake(w, h, x, y)
 TimesPickerView.frame = pickerRect; 
 TimesPickerView.showsSelectionIndicator = YES
  [TimesPickerView setBackgroundColor:[UIColor clearColor]]
 TimesPickerView.autoresizingMask = UIViewAutoresizingFlexibleWidth; 
 TimesPickerView.delegate=self//设置委托 
  [self.view addSubview:TimesPickerView];   //设置默认值,3可以用变量代替,保存数据 
  [TimesPickerView selectRow:3 inComponent:0 animated:YES];   
 
//选项默认值 
-(void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated
-
{ 
  return;
  }   
//设置列数 
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView 
{ 
  return 1
}   
//返回数组总数 
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component
  { 
  return [pickerViewsarray count];//将数据建立一个数组 
}   
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)rowforComponent:(NSInteger)component
  { return [pickerViewsarray objectAtIndex:row];
  if(row==1) 
  { return [pickerViewsarray objectAtIndex:1]
  } 
}  
  //触发事件
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component 
{ [pickerViewsarray objectAtIndex:row]
  switch (row) 
{ case 0: NSLog(@"row:%d",row);
  break
  case 1: NSLog(@"row:%d",row)
  break
  }
// 详细操作,请参照例子UICatalog实例。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值