码迷,mamicode.com
首页 > 其他好文 > 详细

UIPickView

时间:2015-06-14 13:43:24      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

//初始化: 
 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; 
   }

UIPickView

标签:

原文地址:http://www.cnblogs.com/sancaixu/p/4574897.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!