2016-08-10 9 views
3

私は非常に迅速なコーディングに新しいので、私はそれが迅速な使用alertcontrollerでtableviewを表示する方法があることを知りたいです。迅速なiOSのUIAlertcontrollerでUITableviewを表示する方法は?

+0

あなたの要件は何ですか? –

+0

これを一度見てください。http://stackoverflow.com/questions/20737426/how-to-insert-the-uitextview-into-uialertview-in-ios –

+0

ありがとう、私はテーブルビューを表示することができますが、同じ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:{}) 
関連する問題