2016-08-10 2 views
3

나는 신속한 코딩에 매우 익숙하므로 alertcontroller에서 tableview를 신속하게 사용하는 방법을 알고 싶습니다.신속한 IOS의 UIAlertcontroller에서 UITableview를 표시하는 방법은 무엇입니까?

+0

귀하의 요구 사항은 무엇입니까? –

+0

이것을 한 번보기 http://stackoverflow.com/questions/20737426/how-to-insert-the-uitextview-into-uialertview-in-ios –

+0

감사합니다. tableview를 표시 할 수 있지만 동일한 uialertcontroller를 닫는 방법 tableview 셀 클릭? – 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:{})