2016-08-10 6 views
3

Я очень новичок в быстром кодировании, поэтому хочу знать, что есть способ показать tableview в alertcontroller с помощью swift.Как показать UITableview в UIALertcontroller в быстрой iOS?

+0

whats ваше требование? –

+0

см. Этот раз http://stackoverflow.com/questions/20737426/how-to-insert-the-uitextview-into-uialertview-in-ios –

+0

Спасибо, я могу показать tableview, но как отклонить тот же uialertcontroller на щелкнуть по ячейке таблицы? – Harry

ответ

4
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:{}) 

 Смежные вопросы

  • Нет связанных вопросов^_^