UIAlertController中的复选框,其中包含目标c中的操作表

时间:2016-11-11 06:31:36

标签: ios objective-c uialertcontroller uialertsheet

我想在UIAlertAction的一个选项中添加复选框,即uibutton和uilabel 并且只在UIAlertController中的另一个UIAlertAction中按下。

请帮助并建议如何实现它。

 UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"My Alert"
            message:@"This is an action sheet." 
            preferredStyle:UIAlertControllerStyleActionSheet]; // 1
    UIAlertAction *firstAction = [UIAlertAction actionWithTitle:@"one"
            style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
                NSLog(@"You pressed button one");
            }]; // 2
    UIAlertAction *secondAction = [UIAlertAction actionWithTitle:@"two"
            style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
                NSLog(@"You pressed button two");
            }]; // 3

    [alert addAction:firstAction]; // 4
    [alert addAction:secondAction]; // 5

1 个答案:

答案 0 :(得分:0)

尝试这个技巧:

  • 了解如何将ViewController显示为弹出窗口
    • 将UITable添加到ViewController
    • 在UITable中显示项目
    • 通过添加自定义单元格来自定义UITable
    • 在每个自定义单元格中添加一个按钮
    • 该按钮将有两种图像,一个是空白框,另一个是带有复选标记的框
    • 当用户触摸表格单元格时,您需要更改与该表格行对应的按钮图像,以便用户认为他们正在检查或取消选中该框
    • 最后在底部添加一个完成按钮以关闭viewcontroller

谷歌所有这些项目的教程。正如我所说,这不是一项简单的任务,因为Xcode中没有开箱即用的复选标记功能。

来自:https://stackoverflow.com/a/31941282/3901620