Vous pouvez faire défiler un UIPickerView en balayant et en tapotant des éléments sous ou au-dessus de la ceinture de sélection.UIPickerView tap pour faire défiler et afficher des lignes personnalisées UIViews
Vous pouvez remplir un UIPickerView en spécifiant NSString comme titres ou UIViews réutilisables pour chaque ligne. Ce que j'ai remarqué, c'est que quand je suis passé de fournir des chaînes à fournir une vue, appuyez sur pour faire défiler ne fonctionne plus. Est-ce le comportement attendu. Mes vues devraient-elles transmettre certains événements tactiles à l'UIPickerView?
Merci
EDIT:
Voici un exemple de code de mon application:
// Creating the picker
screenPicker_ = [UIPickerView new];
screenPicker_.showsSelectionIndicator = YES;
screenPicker_.delegate = delegate_;
screenPicker_.dataSource = delegate_;
[self addSubview:screenPicker_];
[screenPicker_ release];
// Row view creation delegate
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
PickerRowView *pickerRowView = (PickerRowView*)view;
if(view == nil)
{
pickerRowView = [[PickerRowView alloc] initWithFrame:CGRectMake(0, 0, pickerView.frame.size.width, PICKER_ROW_HEIGHT)];
}
[pickerRowView SetTitle:@"some title"];
return pickerRowView;
}
// initailizer of the PickerRowView class (an UIView subclass)
- (id)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame]))
{
CGFloat titleHeight = frame.size.height * CONTENT_TO_FRAME_RATIO;
title_ = [[UILabel alloc] initWithFrame:CGRectMake(TITLE_X, (frame.size.height - titleHeight)/2, frame.size.width, titleHeight)];
[title_ setFont:[UIFont fontWithName:@"StainlessExt-Light" size:titleHeight]];
title_.backgroundColor = [UIColor clearColor];
[self addSubview:title_];
[title_ release];
self.userInteractionEnabled = NO;
}
return self;
}
Merci, cela fonctionne, mais maintenant la ligne sélectionnée est brièvement en bleu ... –