Add Checkbox List to UIAlertController

家住魔仙堡 提交于 2019-12-02 17:53:10

问题


I am working with the UIAlertController.

Right now I am able to list an item from the following code:

{
  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];
        }

I want to show list on button click in UIAlertController in format shown in below link:

http://imgur.com/bMu2GUc


回答1:


What you had shown in the picture is complicated and cannot be implemented with a simple UIAlertController.

In order to replicate your screenshot what you need is

  • Learn how to show a ViewController as a pop-up
  • Add UITable to a ViewController
  • Show items in a UITable
  • Customize the UITable by adding custom cells
  • In each of the custom cells add a button
  • That button will have two kinds of images, one blank box and the other box with a check mark
  • when user touches a table cell you need to change the button image corresponding to that table row so the user thinks they are checking or unchecking the box
  • and lastly add a done button at the bottom to dismiss the viewcontroller

Google all these items for tutorials. As I said this is not a simple task as there is no out of the box check mark function in Xcode.



来源:https://stackoverflow.com/questions/31939277/add-checkbox-list-to-uialertcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!