我想要
- 显示选择器视图(向上滑动)
- 在可见时停用背景
- 在底部(而不是顶部)显示(UIActionSheet)按钮
起初在我看来这是一个简单的解决方案,因为您可以在网络上的任何地方找到将选择器视图添加到操作表的代码,但是所有解决方案都将按钮放在顶部,我需要将按钮放在操作表的底部(对齐?)。
这可能吗?我想如果我看一下:示例
问候
杰文
已编辑(我的解决方案基于编码的爸爸解决方案)
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil
delegate:nil
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
CGRect pickerFrame = CGRectMake(0, 0, 0, 0);
UIPickerView *pickerView = [[UIPickerView alloc]initWithFrame:pickerFrame];
pickerView.showsSelectionIndicator = YES;
pickerView.dataSource = self;
pickerView.delegate = self;
UISegmentedControl *backButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Back", nil]] ;
[backButton addTarget:self action:@selector(someFunction:) forControlEvents:UIControlEventValueChanged];
backButton.tintColor = [UIColor colorWithRed:0.10 green:0.20 blue:0.52 alpha:0.5];
backButton.segmentedControlStyle = UISegmentedControlStyleBar;
[backButton addTarget:self action:@selector(btnActionCancelClicked:) forControlEvents:UIControlEventAllEvents];
backButton.frame = CGRectMake(20.0, 220.0, 280.0, 40.0);
UISegmentedControl *acceptButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Accept", nil]] ;
[acceptButton addTarget:self action:@selector(anotherFunction:) forControlEvents:UIControlEventValueChanged];
acceptButton.tintColor = [UIColor colorWithRed:0.10 green:0.20 blue:0.52 alpha:0.5];
acceptButton.segmentedControlStyle = UISegmentedControlStyleBar;
acceptButton.frame = CGRectMake(20.0, 280.0, 280.0, 40.0);
[actionSheet addSubview:pickerView];
[actionSheet addSubview:backButton];
[actionSheet addSubview:acceptButton];
[actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];
[actionSheet setFrame:CGRectMake(0,150,320, 400)];
...然后只需应用 iPhone 5/iphone 4 相关视图大小约束
编辑2: 只是另一个提示!最初我想使用标准的 Actionsheet,但不想将pickerview 放在底部。我没有找到如何移动按钮的方法。显然这很简单:在 UIActionSheet 上添加 UIView 作为 subView很高兴知道;)