gpt4 book ai didi

ios - 自定义操作表 IOS swift

转载 作者:行者123 更新时间:2023-11-28 14:27:58 24 4
gpt4 key购买 nike

如何使用 swift 在 ios 应用程序的 webview 上单击按钮上传文件时自定义操作表默认值?

enter image description here

最佳答案

这里的操作表变量是有问题的操作表。您可以给它一个标题和一条消息。然后,您必须使用 UIAlertAction 初始值设定项为您想要的每个操作创建一个变量,在处理程序中,您可以添加每个操作应该执行的操作。

然后您需要将操作分配给您创建的操作表。最后,您应该从负责呈现它的 View Controller 中呈现操作表。

以下是我要解释的内容。

    let actionSheet = UIAlertController(title: "My Action Sheet", message: "My Action Sheet Message", preferredStyle: .actionSheet)
let action1 = UIAlertAction(title: "Action 1", style: .default) { (action) in
//Perform any actions specific to action 1 in your class
}
let action2 = UIAlertAction(title: "Action 2", style: .default) { (action) in
//Perform any actions specific to action 2 in your class
}

let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) //Will just dismiss the action sheet
actionSheet.addAction(action1)
actionSheet.addAction(action2)
actionSheet.addAction(cancelAction)
present(actionSheet, animated: true, completion: nil)

关于ios - 自定义操作表 IOS swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51439302/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com