【问题标题】:How to clear fields after clicking save Swift 3单击保存Swift 3后如何清除字段
【发布时间】:2017-10-19 20:49:51
【问题描述】:

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

enter image description here

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

enter image description here

  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! = ""
    }

【问题讨论】:

  • 重新加载表格视图

标签: uitableview swift3


【解决方案1】:

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

tableview.reloadData()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-03
    • 2012-12-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多