即使没有任何网络操作,UITableView也会在滚动时滞后

时间:2016-01-13 03:09:59

标签: ios swift uitableview tableviewcell

我的项目中有一个非常简单的ViewController.swift原型单元格。我没有网络操作,并且使用硬编码值填充tableview单元格中的数据。滚动时,桌面视图仍然不平滑。我无法弄清楚造成这种滞后的原因。 import UIKit class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } // MARK: Table view delegate and data source func numberOfSectionsInTableView(tableView: UITableView) -> Int { return 1 } func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 20; } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("reviewCell", forIndexPath: indexPath) as! ReviewTableViewCell // cell!.label.text = "\(indexPath.row)" cell.reviewerNameLabel.text = "John Smith" cell.dateLabel.text = "12 months ago" cell.publisherNameLabel.text = "xyz publisher" cell.reviewTextLabel.text = "qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnmqwertyuiop1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnmqwertyuiop1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm1234567890qwertyuiopasdfghjklzxcvbnm" return cell } } 文件的代码如下:

{{1}}

我已经使用故事板设置了tableview和prototype单元格,所以为了简化调试,我已经在github上传了项目。您可以从compiler-generated implementation

获取完整的项目

0 个答案:

没有答案