/ / UIPickerview in iphone - iphone-sdk-3.0, xcode3.2

UIPickerview in iphone - iphone-sdk-3.0, xcode3.2

Come posizionare UIPickerView a livello di codice in una subView senza utilizzare Interface Builder?

risposte:

5 per risposta № 1

Hey! U può rendere UIPickerView a livello di codice ....

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
}

E nella tua classe viewController.h non hai mai dimenticato di farlo

@interface viewController : UIViewController <UIPickerViewDelegate>

Spero che questo possa aiutarti ... per ulteriori aiuti segui il collegamento ..