更新时间:2023-12-04 12:35:04
嘿!您可以通过编程方式制作UIPickerView....
Hey! U can make UIPickerView programmatically....
InviewController.m文件
In- viewController.m file
- (void)viewDidLoad {
[super viewDidLoad];
UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0,100,320, 500)];
[self.view addSubview:pickerView];
[pickerView setDelegate:self];
[pickerView release];
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
return ; //give components here
}
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
return ; //give rows here
}
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { return ; // give titles }
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
//Do the step here
}
在您的viewController.h类中,永远不要忘记这样做
And in your viewController.h class never forgot to do this
@interface viewController : UIViewController <UIPickerViewDelegate>
希望这可能对您有帮助...更多帮助,请按照链接 ..
Hope this may help u.....for more help follow the link ..