0
我创建了一个UIPickerView,它显示在按钮单击上。问题是我如何填写行项目iPhone填充UIPickerView的值
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Location"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0,100,0,0)];
pickerView.showsSelectionIndicator = YES;
pickerView.dataSource = self;
pickerView.delegate = self;
[actionSheet addSubview:pickerView];
[pickerView release];
UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:NSLocalizedString(@"Done", @"")]];
closeButton.momentary = YES;
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];
[closeButton release];
[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];
和点击“完成”时如何获得值。
而不是搞乱管理actionSheet,pickerView等,我会建议使用[EAActionSheetPicker](https://github.com/EckyZero/EAActionSheetPickerDemo)。它真的清理你的代码很多。 – eckyzero 2013-05-22 17:23:12