gpt4 book ai didi

ios - 如何在 iOS 的 UIAlertcontroller 中显示 UITableview?

转载 作者:搜寻专家 更新时间:2023-10-31 08:32:05 26 4
gpt4 key购买 nike

我是 swift 编码的新手,所以我想知道有什么方法可以使用 swift 在 alertcontroller 中显示 tableview。

最佳答案

var alrController = UIAlertController(title: "\n\n\n\n\n\n", message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet)

let margin:CGFloat = 8.0
let rect = CGRectMake(margin, margin, alrController.view.bounds.size.width - margin * 4.0, 100.0)
var tableView = UITableView(frame: rect)
tableView.delegate = self
tableView.dataSource = self
tableView.backgroundColor = UIColor.greenColor()
alrController.view.addSubview(tableView)

let somethingAction = UIAlertAction(title: "Something", style: UIAlertActionStyle.Default, handler: {(alert: UIAlertAction!) in println("something")})

let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: {(alert: UIAlertAction!) in println("cancel")})

alrController.addAction(somethingAction)
alrController.addAction(cancelAction)

self.presentViewController(alrController, animated: true, completion:{})

关于ios - 如何在 iOS 的 UIAlertcontroller 中显示 UITableview?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38864905/

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