我在动作表中添加了一个按钮。这很容易,但在我的情况下,有超过5个,Apple在行动表上不接受更多5个按钮。所以我在动作表中添加了一个滚动视图,并向scrollview添加了按钮。但是这个视图有两个固定的按钮取消,另一个带有一些标题。
这是正确的方法吗?
答案 0 :(得分:6)
如果您有五个以上的按钮,最好在普通视图中使用自定义的表格视图并提供UIModalTransitionStyleCoverVertical
,以便它就像一个操作表
答案 1 :(得分:1)
使用以下代码......
- (IBAction)actionsheetbuttonpress:(id)sender {
actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
UIToolbar *pickerDateToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
pickerDateToolbar.barStyle = UIBarStyleBlackOpaque;
[pickerDateToolbar sizeToFit];
CGRect pickerFrame = CGRectMake(0, 40, 0, 0);
pickerData = [[UIPickerView alloc]initWithFrame:pickerFrame];
pickerData.showsSelectionIndicator = YES;
pickerData.dataSource = self;
pickerData.delegate = self;
[actionSheet addSubview:pickerData];
NSMutableArray *barItems = [[NSMutableArray alloc] init];
UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc]initWithTitle:@"DONE-A" style:UIBarButtonItemStyleBordered target:self action:@selector(DatePickerDoneClick)];
UIBarButtonItem *doneBtn1 = [[UIBarButtonItem alloc]initWithTitle:@"DONE-B" style:UIBarButtonItemStyleBordered target:self action:@selector(DatePickerDoneClick)];
UIBarButtonItem *doneBtn2 = [[UIBarButtonItem alloc]initWithTitle:@"DONE-C" style:UIBarButtonItemStyleBordered target:self action:@selector(DatePickerDoneClick)];
[barItems addObject:doneBtn];
[barItems addObject:doneBtn1];
[barItems addObject:doneBtn2];
//add more two button here...or you can add any no of buttons..
[pickerDateToolbar setItems:barItems animated:YES];
[actionSheet addSubview:pickerData];
[actionSheet addSubview:pickerDateToolbar];
[actionSheet showInView:self.view];
[actionSheet setBounds:CGRectMake(0,0,320, 464)];
[barItems release];
[actionSheet release];
[pickerData release];
}
希望,这会帮助你......冷静