UIPickerView的用法总结

来源:互联网 发布:php中文网视频下载 编辑:程序博客网 时间:2024/06/05 21:56
1.UIPickerView的初始化pickerView =[[UIPickerView alloc] initWithFrame:CGRectMake(0.0f,200.0f,320.0f,216.0f)];pickerView.delegate= self;  //指定DelegatepickerView.showsSelectionIndicator= YES;//显示选中框2.实现UIPickerViewDelegate和UIPickerViewDataSource-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;//返回列数 -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;//返回每列的最大行数 -(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;//每一列中每一行的具体内容 -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component //选中哪一列哪一行 [mypicker selectRow:(NSInteger)3 inComponent:0 animated:YES];