[求助] tableview向上滚动后自定义cell的显示问题? - OurCoders (我们程序员)

OC

[求助] tableview向上滚动后自定义cell的显示问题?

funpig 发布于 2014年12月02日 | 更新于 2014年12月02日
无人欣赏。

我在storyboard里面有一个UITableView和prototype cell,用它来显示一些字符串没有问题

截图

但如果我从xib文件里面加载自定义cell,UITableView的显示和向上滚动后的显示就会有问题

截图

我原来以为是prototype cell影响了自定义cell的显示,在storyboard里面删除prototype cell后问题任然出现,请大家指点下问题在哪? 谢谢!

代码片段如下:

override func viewDidLoad() {
 super.viewDidLoad()
 players = NSMutableArray()
 for i in 1...10 {
 players?.addObject(i)
 }
 var nib : UINib = UINib(nibName: "MyTestCell", bundle: NSBundle.mainBundle())
 self.tableView.registerNib(nib, forCellReuseIdentifier: "MyTestCell")
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
 // UITableViewcell from storyboard
 //let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell
 //let i = players?.objectAtIndex(indexPath.row) as Int
 //cell.textLabel.text = "text " + String(i)
 //cell.detailTextLabel?.text = "detail text (i)"
 //return cell
 // customer UITableViewCell from xib
 var cell = tableView.dequeueReusableCellWithIdentifier("MyTestCell") as MyTestCell
 cell.lable1.text = "lable1 (indexPath.row)"
 cell.lable2.text = "lable2 (indexPath.row)"
 return cell
}

完整工程:

暂无回复
登录 或者 注册
发布新帖
相关帖子
相关新闻
最新帖子

AltStyle によって変換されたページ (->オリジナル) /