refreshControl(拉动刷新)滞后?

时间:2018-04-03 21:16:54

标签: ios swift pull-to-refresh

为什么我的表视图的刷新控制滞后?当它正常时,你可以看到圆圈在360度左右移动,但是当它没有移动时,它只是冻结 - 刷新工作,但它是滞后的。当我刷新x次时,它并不迟钝。但当我离开视图控制器(让我们说A)并转到另一个,然后再创建一个新的A 时,刷新控制滞后。这是我的刷新控件代码:

// Class instance
private var refreshControl = UIRefreshControl()

这就是我设置它的方式:

// In viewDidLoad()
refreshControl = UIRefreshControl()
refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh")
refreshControl.addTarget(self, action: #selector(refreshGroups(_:)), for: .valueChanged)
tableView.refreshControl = refreshControl // >= iOS 10.0

refreshGroups只获取数据并调用tableView.reloadData()

修改

API documentation

This is the working version

编辑2

This is the freeze version

1 个答案:

答案 0 :(得分:0)

我也遇到过这个问题并听取了其他人的意见。帮助我和他们的解决方案是创建一个function Validation() { // Rather than immediately prompt about bad/missing data, prompt only at the end. var msgs = []; // Read all the "occupied" ranges' values into a Javascript "2D" array. var values = SpreadsheetApp.getActiveSheet().getDataRange().getValues(); // Remove the header row from the data. var headers = values.splice(0, 1); // Iterate this array (as opposed to re-querying the Spreadsheet multiple times). // Arrays are 0-based, so cell(1, 12) is array index [0][11]. for (var i = 0; i < values.length; i++) { // If this campaign is not live, there is no reason to validate it. var campaign_live = values[i][11]; if (campaign_live !== "Y") { continue; } var test_type = values[i][6]; if (test_type !== "Subject" && test_type !== "Sender") { msgs.push("Wrong Test Type in Column G, please check."); } var Template = values[i][7]; if (Template !== "HTML" && Template !== "TEXT") { msgs.push("Wrong Template in Column H, please check."); } var Sender = values[i][8]; if (Sender == "" ) { msgs.push("Missing Sender in Column I, please check."); } var Subject = values[i][9]; if (Subject == "" ) { msgs.push("Missing Subject in Column J, please check."); } var Content = values[i][10]; if (Content == "" ) { msgs.push("Missing Content in Column K, please check."); } } // Report any messages that were added. var message = (msgs.length > 0) ? msgs.join("\n") : "Campaign info's been added correctly!"; Browser.msgBox(message); } 实例并为其分配刷新控件。注意:表视图控制器是以编程方式创建的,仅用于刷新控制。

代码可能如下所示:

将这些放入全球范围的课程中:

UITableViewController

这些到let tableViewController = UITableViewController() let refreshControl = UIRefreshControl() 或在您进行设置的任何地方:

viewDidLoad

所有其余部分应该像往常一样处理刷新控制,就像正常情况一样。

希望它有所帮助!如果不是,请记下来。

答案已更新