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

标签 ios swift uitableview uialertcontroller

我是 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/

相关文章:

swift - 沿 X 和 Y Axis 随机生成

objective-c - 主线程或后台线程解析swift

iphone - 在一个类中管理两个 TableView

android - 如何在一个 Firebase 项目中使用两种不同的语言?

javascript - 方向更改后视口(viewport)比例不起作用

ios - 将2个数组组合成字典

ios - 处理键盘后面的 UITextField 的 2 个问题

ios - Swift:返回 UItable View 委托(delegate)和数据源

objective-c - 获取无错误的数值 "Subscript requires size of interface ' NSArray',这在非稳定 ABI 中不是常量”

ios - 如何设置 Tableview 单元格的 alpha 值