swift – 从不调用cellForRowAtIndexPath
发布时间:2020-12-14 04:36:29 所属栏目:百科 来源:网络整理
导读:我正在使用 Xcode 6 beta 7.我有一个故事板,其中包含UIViewController,它有UITableview和UITableViewCell,所有内容都正确连接,我已经为UIViewController提供了所有必需的代码. 当我在模拟器中运行应用程序时,从不调用其中一个数据源函数“cellForRowAtIndexP
我正在使用
Xcode 6 beta 7.我有一个故事板,其中包含UIViewController,它有UITableview和UITableViewCell,所有内容都正确连接,我已经为UIViewController提供了所有必需的代码.
当我在模拟器中运行应用程序时,从不调用其中一个数据源函数“cellForRowAtIndexPath”,但调用“numberOfRowsInSection” >“func tableView(tableView:UITableView,numberOfRowsInSection section:Int) – > Int”被调用 下面是我的视图控制器代码: import UIKit class DVViewController: UIViewController,UITableViewDelegate,UITableViewDataSource { @IBOutlet var tableView : UITableView? var tableData = ["Row 1","Row 2","Row 3"] let kCellID = "cell" override func viewDidLoad() { super.viewDidLoad() self.tableView?.delegate = self; self.tableView?.dataSource = self; //load cell self.tableView?.registerClass(UITableViewCell.self,forCellReuseIdentifier: kCellID); self.tableView?.reloadData(); } //MARK: Tableview delegates func tableView(tableView: UITableView,numberOfRowsInSection section: Int) -> Int { return self.tableData.count; } func tableView(tableView: UITableView,cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { //var cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Default,reuseIdentifier: kCellID) let cell : UITableViewCell = UITableViewCell (style: UITableViewCellStyle.Default,reuseIdentifier: kCellID); return cell; } } 有人可以建议为什么从不调用“cellForRowAtIndexPath”,它曾经在Xcode6 beta 2中工作. 解决方法
这是我做的,卸载Xcode 5& 6只重新安装的Xcode 6,Ran项目和它工作.经过2天的调试后,重新安装完成了这个技巧.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |