如何在单击保存后清除字段 Swift 3.



所以,我有一个看起来像这样的表视图。

在此处输入图像描述

这就是字段为空时的样子。单击行后,我可以选择选项,然后它看起来像第二张图像。但是,在此屏幕上单击保存后,我希望清除所有这些字段。我已经尝试了这样的代码并将其放置在我的视图"将出现"选项卡中。由于此视图由选项卡栏控制器访问,因此 viewDidLoad 不会调用,但它仍然不起作用。有人可以告诉我单击保存后如何清除字段。

在此处输入图像描述

  self.categoryDisplayed = ""
    self.collectionsDisplayed = ""
    self.currencyNameDisplayed = ""
    let indexpath = NSIndexPath(row: 0, section: 0)
    let cell = tableView.dequeueReusableCell(withIdentifier: "listCell", for: indexpath as IndexPath) as! ListDataTableViewCell

    if (!self.isMovingToParentViewController){
        self.categoryDisplayed = ""
        self.collectionsDisplayed = ""
        cell.optionSelectedLabel.text! = ""
    }

您可以像这样重新加载数据:

tableview.reloadData()

最新更新