大佬教程收集整理的这篇文章主要介绍了ios – 自动刷新tableview,无需刷新,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@IBOutlet weak var allPrayerrequestsTableView: UITableView! var timer = NSTimer.scheduledTimerWithTimeInterval(0.4,target: self,SELEctor: "update",userInfo: nil,repeats: truE) func update() { allPrayerrequestsTableView.reloadData() }
dispatch_async(dispatch_get_main_queue()) { self.allPrayerrequestsTableView.reloadData() }
func update() { dispatch_async(dispatch_get_main_queue()) { self.allPrayerrequestsTableView.reloadData() } }
示例代码:
import UIKit class ViewController: UIViewController,UITableViewDatasource,UITableViewDelegate { @IBOutlet weak var allPrayerrequestsTableView: UITableView! var tableArray = [Int]() var count = 0 override func viewDidLoad() { super.viewDidLoad() allPrayerrequestsTableView.registerClass(UITableViewCell.self,forCellReusEIDentifier: "cell") allPrayerrequestsTableView.delegate = self allPrayerrequestsTableView.datasource = self var timer = NSTimer.scheduledTimerWithTimeInterval(1,repeats: truE) } func tableView(tableView: UITableView,numberOfRowsInSection section: int) -> Int{ return tableArray.count } func tableView(tableView: UITableView,cellForRowATindexPath indexPath: NSIndexPath) -> UITableViewCell{ var cell:UITableViewCell = tableView.dequeueReusableCellWithIdentifier("cell") as! UITableViewCell cell.textLabel?.text = "\(tableArraY[indexPath.row])" return cell } func update() { count++ //update your table data here tableArray.append(count) dispatch_async(dispatch_get_main_queue()) { self.allPrayerrequestsTableView.reloadData() } } }
HERE是最终项目.
以上是大佬教程为你收集整理的ios – 自动刷新tableview,无需刷新全部内容,希望文章能够帮你解决ios – 自动刷新tableview,无需刷新所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。