问题
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