0
我已将UIPickerView添加到UIActionSheet中。一切正常,但我的选择器无法滚动选择一个值。有什么建议么?UIPickerView不在动作中滚动表
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
UIPickerView * picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 50, 320, 270)];
picker.showsSelectionIndicator = YES;
picker.dataSource = self;
picker.delegate = self;
[actionSheet addSubview:picker];
[picker release];
[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0, 0, 320, 500)];
[actionSheet release];
最好的问候, 多兰基尔托
测试此代码。它没有问题。你已经实现了什么'delegate'和'dataSource'方法? – 2011-05-23 14:32:20
- (NSInteger)numberOfComponentsInPickerView :(UIPickerView *)pickerView; { return 1; } - (无效)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger的)行inComponent:(NSInteger的)分量{ } - (NSInteger的)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger的)组分; { return [array count]; (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)组件; { return [array objectAtIndex:row]; } – 2011-05-23 14:40:42
我把这段代码放到方法textFieldShouldBeginEditing中。在编辑模式下进入时,我想为textField启用值选择。在这种情况下,我的选择器似乎不知何故被禁用。当我将代码粘贴到didLoad方法中时,一切正常。 – 2011-05-23 14:48:53