ios – 如何修复非法配置?

前端之家收集整理的这篇文章主要介绍了ios – 如何修复非法配置?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个.xib文件,我希望它是一个表视图控制器,但是当我在.xib文件中创建一个表视图控制器时,我得到错误表视图包含嵌入的部分和单元格仅在故事板文档中受支持.我该如何解决.下面是我的实际表视图的代码.
self.add = [Play(name: title!),Play(name: artist!),Play(name: album!)]

override func tableView(tableView: UITableView,numberOfRowsInSection section: Int) -> Int {
    return self.add.count
    //return count of objects in array
}

override func tableView(tableView: UITableView,cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = self.tableView.dequeueReusableCellWithIdentifier("Cell",forIndexPath: indexPath) as! UITableViewCell
    var play: Play

    play = add[indexPath.row]

    cell.textLabel?.text = play.name
    return cell
}

解决方法

Xibs有点陈旧,当它们被发明时,没有你可以在UI构建器中制作的原型单元格.当故事板被引入时,这个功能也被制作出来了,除了没有后端移植到xib编辑器,所以不幸的是你不能在xib中使用原型单元,你需要为单元格布局制作单独的xib.
原文链接:https://www.f2er.com/iOS/333562.html

猜你在找的iOS相关文章