Ios 保存来自警报消息swift的输入
我有一个问题,无法将警报消息的输入显示到表视图中。没有错误,但我不知道是什么真正的问题使表空了Ios 保存来自警报消息swift的输入,ios,swift,uitableview,uialertcontroller,Ios,Swift,Uitableview,Uialertcontroller,我有一个问题,无法将警报消息的输入显示到表视图中。没有错误,但我不知道是什么真正的问题使表空了 import UIKit import Parse class ViewController: UIViewController ,UITableViewDelegate,UITableViewDataSource{ @IBOutlet weak var childTbl: UITableView! var names=[String] () override func v
import UIKit
import Parse
class ViewController: UIViewController ,UITableViewDelegate,UITableViewDataSource{
@IBOutlet weak var childTbl: UITableView!
var names=[String] ()
override func viewDidLoad() {
super.viewDidLoad()
self.childTbl.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
}
@IBAction func Addchild(sender: AnyObject) {
var alert=UIAlertController(title: "",
message: "إضافة طفل جديد",
preferredStyle: .Alert)
alert.addTextFieldWithConfigurationHandler({(textField) -> Void in
textField.text=""
})
alert.addAction((UIAlertAction(title: "حفظ", style: .Default, handler: { (ACTION) -> Void in
self.dismissViewControllerAnimated(true, completion: nil)
if let textField = alert.textFields!.first as?UITextField{
self.names.append(textField.text)
println(self.names)
}
})))
alert.addAction((UIAlertAction(title: "إلغاء", style: .Default, handler: { (ACTION) -> Void in
self.dismissViewControllerAnimated(true, completion: nil)
})))
//to display the alert
presentViewController(alert,
animated: true,
completion: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//UITabledatasource
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return self.names.count;
}
//function to creat a cell
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
var cell:UITableViewCell = self.childTbl.dequeueReusableCellWithIdentifier("cell") as! UITableViewCell
cell.textLabel?.text = self.names[indexPath.row]
return cell
}
}
看起来您没有调用childTbl reload以便重新加载数据并显示添加到名称目录中的新信息。您好,我忘记了,多亏了LOT,这不是问题。我只是在警报消息中添加了更多文本字段,我想显示文本字段的第一个输入,即“名称”在表视图的单元格中,我希望保存其他输入,以便用户在选择引用它们的名称后可以看到它们