Checkbox in UIAlertController with actionsheet in objective c [duplicate]

送分小仙女□ 提交于 2019-12-13 05:43:05

问题


I want to add the checkbox i.e uibutton and uilabel in one option in UIAlertAction and only button in another UIAlertAction in UIAlertController.

Please help and advice how to achieve it.

 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:


Try this trick :

  • 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.

From : https://stackoverflow.com/a/31941282/3901620



来源:https://stackoverflow.com/questions/40542361/checkbox-in-uialertcontroller-with-actionsheet-in-objective-c

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