将复选框列表添加到 UIAlertController

Add Checkbox List to UIAlertController

我正在使用 UIAlertController

现在我可以通过以下代码列出项目:

{
  UIAlertController *controller = [UIAlertController alertControllerWithTitle: @"Beds"
                                                                            message: @""
                                                                     preferredStyle: UIAlertControllerStyleAlert];
        [controller.view setBackgroundColor:[UIColor clearColor]];
        [controller.view setTintColor:[UIColor blackColor]];

        for (int a=0;a<[bedsCount count];a++)
        {

            UIAlertAction *button = [UIAlertAction actionWithTitle: [bedsCount objectAtIndex:a]
                                                             style:UIAlertActionStyleDefault
                                                           handler:^(UIAlertAction *action)
                                     {
                                         [bedSelectionText setTitle:[bedsCount objectAtIndex:a] forState:UIControlStateNormal];


                                     }];
            [controller addAction: button];
        }

我想在 UIAlertController 中点击按钮显示列表,格式如下 link:

http://imgur.com/bMu2GUc

你在图片中显示的内容很复杂,无法用简单的 UIAlertController 实现。

要复制您的屏幕截图,您需要的是

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

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