UIAlertController中的复选框以及目标c中的动作表 [英] Checkbox in UIAlertController with actionsheet in objective c

查看:210
本文介绍了UIAlertController中的复选框以及目标c中的动作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在UIAlertAction的一个选项中添加复选框,即uibutton和uilabel 并且是UIAlertController中另一个UIAlertAction中的唯一按钮.

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

推荐答案

尝试一下技巧:

  • 了解如何将ViewController显示为弹出窗口
    • 将UITable添加到ViewController
    • 在UITable中显示项目
    • 通过添加自定义单元格来自定义UITable
    • 在每个自定义单元格中添加一个按钮
    • 该按钮将包含两种图像,一个是空白框,另一个是带有复选标记的框
    • 当用户触摸表格单元格时,您需要更改与该表格行相对应的按钮图像,以便用户认为他们正在选中或取消选中该框
    • 最后在底部添加完成按钮以关闭视图控制器
    • 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所有这些项目均用于教程.就像我说的那样,这不是一个简单的任务,因为Xcode中没有开箱即用的选中标记功能.

      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/a/31941282/3901620

      这篇关于UIAlertController中的复选框以及目标c中的动作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆