vignesh TN vignesh TN - 4 months ago 142
Swift Question

How to add UITableView in a UIAlertView in swift

How do I dynamically add UITableView in UIAlertView. After adding subView of UIAlertView to UITableView it is not displayed.

override func viewDidLoad() {
super.viewDidLoad()
tableView.frame = CGRectMake(0, 50, 320, 200);
tableView.delegate = self
tableView.dataSource = self
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
}

@IBAction func textFieldCliked(sender: AnyObject) {
alertView.message = "table view"
alertView.addButtonWithTitle("Ok")
alertView.addSubview(tableView)
alertView.show()
}

Answer

I dont think you can do that with UIAlertView, but you can make a small View and present it modally or something like UIPopoverPresentationController