var weibos :[Int]?;
...
self.loadData();
...
func loadData(){
//WeiboModel.loadData(0, max_id: 0) { (list, error) -> () in
self.weibos = [];
for(var i=0;i<10;i++){
self.weibos?.append(i);
}
print("不管有没有注释WeiboModel.loadData 都能执行到这里");
//}
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
print("微博条数\(weibos?.count)");
return weibos?.count ?? 0
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell();
cell.textLabel?.text = String(weibos?[indexPath.row]);
return cell;
}
以上是一个ios uitableview的代码,
运行app后能在界面中显示出10行的单元格。
但是,如果我把WeiboModel.loadData这个方法不注释的话。
下面向数组添加元素照样能执行到,并且数组里也有值,但tableVIew的几个代理方法全部失效了。
不管tableView.reloadData(),还是改变数组的值,单元格都不显示。
求帮助,调试一整天了。。。。。。。。。。
代码:https://github.com/iScript/swift-project/blob/master/ySeed/HomeViewController.swift
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
。。。。。。。。