首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >断言失败in -[UITableView UITableView

断言失败in -[UITableView UITableView
EN

Stack Overflow用户
提问于 2013-12-11 07:29:37
回答 1查看 2.5K关注 0票数 0

我使用的是Xcode 5.0.2,iOS7。我使用导航控制器和表视图。

我将表视图“内容”从动态原型更改为静态单元格,然后就崩溃了。在崩溃之前,应用程序运行正常。拜托救救我。谢谢。

dequeueReusableCellWithIdentifier:forIndexPath:,/SourceCache/UIKit/UIKit-2903.23/UITableView.m:5261中的断言失败 2013年-12-11 23:04:12.952 Wop9339:60b *终止应用程序由于非正常异常'NSInternalInconsistencyException',原因:“无法用标识符单元格排成队列-必须为标识符注册一个nib或类,或者在情节提要中连接一个原型单元格”

*第一次抛出调用堆栈:

(0x30cdfe83 0x3b03c6c7 0x30cdfd55 0x316880af 0x335d015f 0x240bf 0x33596315 0x3353e6cd 0x3353def1 0x33464353 0x330ea943 0x330e6167 0x33115425 0x334e118f 0x334df7f7f9 0x334dea37 0x334de9bf 0x334de957 0d7459 0x33a397 0x334de6a9 0x334DE6d 0x33417 0x46f5x5x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x4x430x430x0x0x430x0x430x0x0x0x430x0x30x350x0x0x3x350x0x0x3230x0x30x350230x0x31688050)0x3x31688050(0x30x30x350x0x30x350cf83 0x30x3b03c6c7)0x3x316880f 0x3x015f 0x4x240bf 0x3359370x3353e6f1 0x3353f1/0x3353e6f1 0x3353f1 0x33430x430x303030x350x943 0x33030+0x30x30x350x30x30x350x30x30cfd55 0x31688050 0x3x316880 0x335015f 0x240bf libc++abi.dylib:以NSException类型的未明确例外结束 (十一分贝)

12/15 12:37我很抱歉问了这个类似的问题,这是我第一次学习语言,我不知道我应该输入什么关键词。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-11 08:06:40

当创建一个比从UITableViewController继承的视图控制器时,已经包含了以下方法:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

如果您没有使用动态原型,那么这些方法是不需要的,应该删除。

当您的表视图加载时,它正在调用cellForRowAtIndexPath (如果numberOfSectionsInTableViewnumberOfRowsInSection返回的数字不是0),它试图创建一个标识符为" cell“的单元格。它找不到带有此标识符的原型单元格,因为您已经将表设置为使用静态单元格,因此得到了异常。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20523134

复制
相关文章
UITableView 组件化
在 iOS 开发中,UITableView 可以说是最常用的控件。几行代码,实现对应方法,系统就会给你呈现一个 60 帧无比流畅的列表,让初学者成就感爆棚。然而随着开发的深入,我们就会慢慢觉察到当前的 UITableView 实现会有这样或那样的问题。
猿_人类
2019/09/03
1.5K0
UITableView 组件化
IOS UITableView 表格嵌套
自定义表格控件:CustomizeUITableViewCell.swif //自定义单元格,单元格高度动态调整 1 import UIKit 2 3 class CustomizeUITableViewCell:UITableViewCell, UITableViewDataSource, UITableViewDelegate { 4 5 var tableView:UITableView!; 6 var comments:[String] = [] 7 8 override init
用户5760343
2019/07/08
1K0
IOS UITableView 表格嵌套
iOS UITableView的使用
添加代理 UITableViewDelegate,UITableViewDataSource
码客说
2019/10/22
8660
【iOS开发】UITableView优化
移动开发中,任何一个应用都或多或少的有列表的存在,列表的上下滑动直接关系到用户体验。如果处理不好,就会使得列表滑动起来有明显的卡顿效果。所以对列表的优化,让它更加的顺滑,就成了移动开发工程师们一直努力的方向。下面就说说一些通用的列表优化,很多优化还是要到具体的列表环境中。欢迎交流。
吴老师
2018/09/05
1.8K0
IOS UITableView UITableViewCell控件
import UIKit class ViewController:UIViewController,UITableViewDataSource { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view,typically from a nib. let screenRect = UIScreen.main.bounds let tableRect = CGRect(x:0, y:20, width: screenRect.size.width, height:screenRect.size.height - 20) let tableView = UITableView(frame:tableRect) tableView.dataSource = self self.view.addSubview(tableView) } func tableView(_ tableView:UITableView,numberOfRowsInSection section:Int) -> Int{ return 20 } func tableView(_ tableView:UITableView,cellForRowAt indexPath:IndexPath) -> UITableViewCell { let identifier = “reusedCell” var cell =tableView.dequeueReusableCell(withIdentifier:identifier) if(cell == nil) { cell = UITableViewCell(style:UITableViewCellStyle.default, reuseIdentifier:identifier) } cell?.textLabel?.text = “命运负责洗牌,玩牌的是我们自己!” return cell! } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }
用户5760343
2019/07/08
6530
IOS UITableView UITableViewCell控件
UITableView reloadData或viewWillAppear失效
后来发现原来用了UINavigationController后,viewWillAppear方法是没有效果的,要用UINavigationControllerDelegate的– navigationController:willShowViewController:animated:方法才可以达到这个目的。
EltonZheng
2021/01/22
6010
UITableView实践(一):实现原理
我们知道在iOS上开发的视图使用UIKit,Mac OS则没有。Chameleon项目就是将UIKit的代码也可以运行在macOS上。我们可以通过Chameleon项目的源码来一探究竟,UITableView是如何实现的。
Helloted
2022/06/07
9610
UITableView实践(一):实现原理
UITableView增加和删除、移动
1、在控制器上添加一个UITableView,  暂时该UITableView控件变量名命名为为tableView, 设置控件代理,实现控制器的UITableViewDataSource, UITableViewDelegate协议;
tandaxia
2018/09/27
1.8K0
UITableView增加和删除、移动
iOS WKWebView+UITableView混排
WKWebView+UITableView混排 做内容展示页的时候,经常会用到WKWebView+UITableView的混排功能,现在此做一个总结,该功能的实现我采用了四种方法。 方案1: webView作为tableView的Header, 撑开webView,显示渲染全部内容,当内容过多时,比如大量高清图片时,容易造成内存暴涨(不建议使用),此方案简单粗暴 , 仅适用于内容少的场景,具体实现不在此赘述,直接看代码。 方案2: 简书的内容页实现方案 : UIWebView与UITableV
且行且珍惜_iOS
2020/06/09
1.7K0
iOS  WKWebView+UITableView混排
优雅的使用UITableView
在我们iOS开发中UITableView几乎是所有App都会使用的一个UI控件,因为业务的需要,我们常常会注册多种Cell,然后在
会写bug的程序员
2020/06/06
9980
优雅的使用UITableView
UITableView 刷新指定行
// 一个section刷新 NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndex:1]; [tableview reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic]; //collection 相同 // 刷新某一行 NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSect
编程那点事
2023/02/25
6960
UITableView性能优化-中级篇
老实说,UITableView性能优化 这个话题,最经常遇到的还是在面试中,常见的回答例如:
小蠢驴打代码
2018/12/27
1.6K0
iOS_UITableView性能优化
// 滑动时按需加载, 防止卡顿 配合SDWebImage https://github.com/johnil/VVeboTableViewDemo
mikimo
2022/07/20
6450
iOS-UITableView 详解(一)
iOS-UITableView 详解 (一) ✨建议收藏,用到时候一查就明白了 UITableView可以说是iOS开发中最重要的控件之一,它的使用非常广泛,今天我们来学习UITableView的使
xx_Cc
2018/05/10
1.5K0
Swift 2.0 UItableView 的简单使用
在IOS开发中,UItableView 的使用真的是最常见最普通的了,现在在自学swift 今天也是这用Swift 写了写 UItableview的使用,还有一些经常出错的地方。下面我先把整个控制器的代理列出来,大家可以顺便看看 swift 是怎样遵守协议的。 import UIKit // 遵守两个协议 class HomeViewController: UIViewController ,UITableViewDelegate,UITableViewDataSource { override
Mr.RisingSun
2018/01/09
1.8K0
UITableView 编辑状态(删除、添加、移动)
----- TableView 删除和添加 ----- ** UITableView 编辑步骤 1.让 tableView 处于编辑状态 2.协议确定 1)确定 cell 是否处于编辑状态 2)设定 cell 的编辑样式(删除、添加) 3) 编辑状态进行提交** 开启编辑状态 //1.让 tableView 处于编辑状态 [tableView setEditing:YES animated:YES]; 如果
LeeCen
2018/10/11
1.5K0
UITableView 编辑状态(删除、添加、移动)
UITableView在Flutter中是什么?
前面我们学习了文本、图片和按钮这些基本元素,这些基本元素需要进行排列组合,才能构成我们看到的UI视图。那么,当这些基本元素的排列布局超过屏幕显示尺寸(即超过一屏)时,我们就需要引入列表控件来展示视图的完整内容,并根据元素的多少进行自适应滚动展示。
拉维
2019/08/12
5.6K0
UITableView在Flutter中是什么?
iOS中表视图(UITableView)使用详解
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style;  
珲少
2018/08/15
1.4K0
UITableView性能提升和优化(第
在重用cell之后,你可以再一次测试滚动性能。从表格3-3可以看出,在你正确重用cell之后,性能提升了一倍。
py3study
2020/01/08
6810
UITableView性能提升和优化(第
使用UITableView 简化登录注册界面
感觉有些时间没写iOS的东西了,主要是大神们都已经把该讲的都讲清楚了,<code>实在不敢弄斧班门</code>前段时间看到一篇巧用状态值处理复杂的 TableView文章,思路另辟蹊径,值得学习,但通篇看下来后<code>发现没有code demo,有些撩人啊</code>,本着学习的态度,根据该文章的方法,写了个示例工程loginTableDemo,希望能对看了该文章的人在实践上有所帮助,同时欢迎大家指出代码中的不足,<code>没有优化处理,有不少冗余的code</code>. 不废话,先上效果:
代码行者
2018/08/23
1.1K0
使用UITableView 简化登录注册界面

相似问题

> -[UITableView UITableView中的断言失败“

47

断言失败-[UITableView _endCellAnimationsWithContext:

30

断言失败-[UITableView _endCellAnimationsWithContext]

31

UITableView CoreData断言失败

13

断言失败in -[UITableView layoutSublayersOfLayer:]

23
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文