
当我在模拟器中运行应用程序时,从不调用其中一个数据源函数“cellForRowAtIndexPath”,但调用“numberOfRowsInSection”
>“func tableVIEw(tableVIEw:UItableVIEw,numberOfRowsInSection section:Int) – > Int”被调用
>但是“func tableVIEw(tableVIEw:UItableVIEw,cellForRowAtIndexPath indexPath:NSIndexPath) – > UItableVIEwCell”从未被调用过
下面是我的视图控制器代码:
import UIKitclass 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天的调试后,重新安装完成了这个技巧. 总结以上是内存溢出为你收集整理的swift – 从不调用cellForRowAtIndexPath全部内容,希望文章能够帮你解决swift – 从不调用cellForRowAtIndexPath所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)