微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

swift – 从不调用cellForRowAtIndexPath

我正在使用 Xcode 6 beta 7.我有一个故事板,其中包含UIViewController,它有UITableview和UITableViewCell,所有内容都正确连接,我已经为UIViewController提供了所有必需的代码. @H_404_5@

@H_404_5@当我在模拟器中运行应用程序时,从不调用其中一个数据源函数“cellForRowAtIndexPath”,但调用“numberOfRowsInSection”

@H_404_5@>“func tableView(tableView:UITableView,numberOfRowsInSection section:Int) – > Int”被调用
>但是“func tableView(tableView:UITableView,cellForRowAtIndexPath indexPath:NSIndexPath) – > UITableViewCell”从未被调用

@H_404_5@下面是我的视图控制器代码

@H_404_5@

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;
    }
}
@H_404_5@有人可以建议为什么从不调用“cellForRowAtIndexPath”,它曾经在Xcode6 beta 2中工作.

解决方法

这是我做的,卸载Xcode 5& 6只重新安装的Xcode 6,Ran项目和它工作.经过2天的调试后,重新安装完成了这个技巧.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐