- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
由于某种原因,我的应用程序在尝试将单元格加载到表格 View 时失败。我在整个应用程序中的所有表格 View 都完全相同,我对它们没有任何问题。这可能与从另一个 viewController 初始化 Controller 有关吗?我不这么认为。我在 Storyboard 中的单元格已获得标识符。这是屏幕截图的链接。
所以我什么都试过了here但没有任何效果。
这是使用 [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath] 方法的输出:
2013-11-14 15:36:33.419 ComplyOS[43683:70b] *** Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2903.23/UITableView.m:5261
2013-11-14 15:36:33.424 ComplyOS[43683:70b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier ProcedureCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
*** First throw call stack:
(
0 CoreFoundation 0x0000000101fa9795 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000101d0c991 objc_exception_throw + 43
2 CoreFoundation 0x0000000101fa961a +[NSException raise:format:arguments:] + 106
3 Foundation 0x00000001018a99e9 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
4 UIKit 0x00000001008f9879 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 150
5 ComplyOS 0x00000001000099b4 -[EndoPxTableViewController tableView:cellForRowAtIndexPath:] + 116
6 UIKit 0x0000000100902b8a -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 348
7 UIKit 0x00000001008ea836 -[UITableView _updateVisibleCellsNow:] + 2297
8 UIKit 0x00000001008fb381 -[UITableView layoutSubviews] + 207
9 UIKit 0x0000000100892b27 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 354
10 QuartzCore 0x00000001005afa22 -[CALayer layoutSublayers] + 151
11 QuartzCore 0x00000001005a4589 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 363
12 QuartzCore 0x00000001005a440a _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
13 QuartzCore 0x0000000100519694 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 252
14 QuartzCore 0x000000010051a70c _ZN2CA11Transaction6commitEv + 394
15 QuartzCore 0x000000010051ad79 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
16 CoreFoundation 0x0000000101f74ff7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
17 CoreFoundation 0x0000000101f74f67 __CFRunLoopDoObservers + 391
18 CoreFoundation 0x0000000101f546d2 __CFRunLoopRun + 946
19 CoreFoundation 0x0000000101f53f33 CFRunLoopRunSpecific + 467
20 GraphicsServices 0x0000000103c2b3a0 GSEventRunModal + 161
21 UIKit 0x0000000100837043 UIApplicationMain + 1010
22 Comply 0x0000000100002703 main + 115
23 libdyld.dylib 0x00000001029ed5fd start + 1
24 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
这是我的 UITableView Controller 代码:
#import "EndoPxTableViewController.h"
#import <AFHTTPRequestOperationManager.h>
#import "ProcedureTableViewCell.h"
@interface EndoPxTableViewController (){}
@property (nonatomic, strong)NSArray *procedures;
@end
@implementation EndoPxTableViewController
- (void)setVisitItem:(Patient_VisitsModel *)visitItem{
if(_visitItem !=visitItem){
_visitItem = visitItem;
}
}
-(void)setUserId:(NSString *)userId{
if(_userId !=userId){
_userId = userId;
}
[self fetchProceduresData];
}
- (void) fetchProceduresData{
NSString *procedureURLString =[NSString stringWithFormat:@"https://XXXX";
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:procedureURLString parameters:nil success:^(AFHTTPRequestOperation *operation, id json) {
_procedures = json;
[self.tableView reloadData];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error occured in getSessionID method");
NSLog(@"Error: %@", error);
}];
}
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Endoscopy Report";
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSLog(@"Procedures:%@", [_procedures valueForKey:@"description"]);
return _procedures.count;
}
- (ProcedureTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ProcedureCell";
ProcedureTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSString *procedureDescription = [_procedures[indexPath.row] valueForKey:@"description"];
NSLog(@"Procedure Description:%@", procedureDescription);
cell.procedureLabel.text = procedureDescription;
cell.questionImage.image = nil;
return cell;
}
#pragma mark - Navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
}
@end
感谢大家的帮助。我有点绝望了。
最佳答案
我的错!您似乎正在使用 dequeueReusableCellWithIdentifier:forIndexPath:
方法来使单元格出列。请尝试使用 dequeueReusableCellWithIdentifier:
,它应该可以工作。
dequeueReusableCellWithIdentifier:forIndexPath:
需要一个 nib 文件或一个注册类来使单元格出队,但您使用的是 Storyboard原型(prototype)单元格。如果您使用正确的标识符,dequeueReusableCellWithIdentifier:
保证从 Storyboard 中返回一个单元格。
希望对您有所帮助。
关于ios - -[UITableView dequeueReusableCellWithIdentifier :forIndexPath:] 断言失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19989266/
我有以下实体字段: /** * @Assert\Regex( * pattern = "/^d+\.(jpg|png|gif)$/", * htmlPattern = "/^d+\.(j
我有一个显示查询结果的表。 我使用这个检查表包含结果: cy.get("table", {timeout: 60000}).find("tr[data-index]").should("have.le
void (assert)(int e) { assert(e); } 这里是如何工作的? 最佳答案 void (assert)(int e) 相当于 void assert(int) 为什么
大家好,我的第一次测试遇到了一些问题 我正在写这个 fragment ,但我一直遇到这个问题: java.lang.AssertionError at org.junit.Assert.fail(As
从表中,我获取字符串列表,并想检查当 val!= "A"时,表列表中是否存在字符串“x”: for (int i = 0; i list = new ArrayList(); for(int i=0
我想在现有代码中为 VHDL 断言操作添加一个错误计数器。基本上,我的代码如下所示: assert data = good_data report "Bad data" severity er
我有一个无法处理的问题,所以我想也许你可以帮助我。基本上我有一个函数,它接收 char* 作为参数并对其执行一些操作(我已经检查了这些步骤/函数,它们工作得很好)。如果函数中给出的 char* 是“”
我有一些代码用于检查输入日期是否正确。只需检查是否不超过 12 个月,给定月份中的日期是否正确,并且还应该考虑闰年(因此,基本上是正常的日期检查)。唯一不合适的是年份不应低于 2000。如果日期无效,
我有一个关于 Cypress 断言的问题,最近才开始使用这个测试平台,但是当 URL 返回一个随机数时卡住了,如下所示。 /Geocortex/Essentials/REST/sites/SITE?f
我有一个 Python mock对象,我想断言是否设置了该对象的任何属性。 我不相信PropertyMock将适用于我的目的,因为我必须知道是否设置了任何属性,而不是特定属性。 它也不像我可以模拟模拟
考虑这个简单的基类 Foo 有一个函数 foo 调用一个纯虚函数 foo_,用 Doxygen 记录: class Foo { public: /** \brief This functi
关闭。这个问题需要debugging details .它目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and th
我在这段代码中执行 malloc 时遇到问题, /*function starts*/ if(NULL==(partial_results=(bignum_t**)malloc(sizeof
大家好,我想知道如何将整个代码块放入一个断言中? 例如,我有一个数组,我想对数组的每个值进行断言。这是我的代码的样子: for (int value : values) { assert Wi
这不是我的作业——我只是在练习。我似乎无法完全理解这个断言概念。 1) Determine the pre-condition for x that guarantees the post-condi
是否可以在带有时间戳的断言失败时记录信息 例如 int a = 10 assert( a > 100 ); 那么它将失败并像时间戳一样输出 2013-12-02 , 17:00:05 assert f
由于我们公司不使用单元测试,所以我正在自学对自己的代码进行单元测试。我正在使用标准的 .net 测试框架进行一些非常基本的单元测试。 我的一个方法返回一个 IEnumerable我想测试它的输出。所以
我有一个如下所示的对象数组,并且只想针对数组中的某些字段进行断言。 对象数组 - var a = [{"key":"key2","value":"value2","updatedBy":"name1"
我正在尝试编写一个 PSL 断言来检查输入断言的数量是否与输出断言的数量相匹配。 例如: . 在输入上任何时候都可能发生任何事情,输出也可以在任何时候断言。确切时间未知,也不重要。我要验证的是没有信息
我想在Cypress中做一个断言如下: cy.get(a).should('be.visible').or(()=>{ cy.get(b).should('be.visible'); });
我是一名优秀的程序员,十分优秀!