How to place UIPickerView programmatically in a subView with out using Interface Builder?
Asked
Active
Viewed 1,661 times
0
-
you won't get an answer to 'plz send me teh codez'. You must show what you've tried, what you've found, what does/doesn't work and you'll get help with a solution. Google (or even search within SO) is your friend. – KevinDTimm Dec 30 '10 at 04:37
1 Answers
5
Hey! U can make UIPickerView programmatically....
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
}
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 ..
-
I have 5 main views.I have to place this UIPicker in subView(name as myView) and pickerView displays "1 - 30" values. Can u send me, how can i do this? – user553215 Dec 30 '10 at 05:47
-
awesome! @user553215 show respect with voting up for that nice answer ;) – Lior Frenkel May 08 '11 at 04:45