Ios UITableView数据源必须返回UIPopoverController中的单元格
我有一个UIPopoverController显示一个表视图 我得到一个崩溃,根据: ,/SourceCache/UIKit_Sim/UIKit-2935.137/UITableView.m:6509 2015-05-06 17:12:05.795下一步[39510:607]*由于未捕获的异常“nSinternalinconsistenceexception”终止应用程序,原因:“UITableView数据源必须从tableView返回单元格:cellForRowAtIndexPath:” *第一次抛出调用堆栈: ( 0 CoreFoundation 0x037691e4例外预处理+180 1 libobjc.A.dylib 0x0341e8e5 objc_异常_抛出+44 2 CoreFoundation 0x03769048+[N异常提升:格式:参数:][136 3基金会0x01484DE-[ NSRealStutsHuffer-HeaveReuluIn方法:对象:文件:文件号:描述:] + 116 4 UIKit 0x025c0d7f\uuuu 53-[UITableView\uConfigureCellForDisplay:forIndexPath:]\uBlock\uInvoke+426 如果我将节中的numberOfRows设置为0,我将看到tableView 如果我将行数设置为1,则会发生此崩溃,因此将显示表格,并且需要显示单元格 CellForRowAtIndexPath从未调用过,因此崩溃。这是为什么 在IB中正确设置了委托和数据源 其已根据以下内容启动并提交查看:Ios UITableView数据源必须返回UIPopoverController中的单元格,ios,iphone,uitableview,uipopovercontroller,Ios,Iphone,Uitableview,Uipopovercontroller,我有一个UIPopoverController显示一个表视图 我得到一个崩溃,根据: ,/SourceCache/UIKit_Sim/UIKit-2935.137/UITableView.m:6509 2015-05-06 17:12:05.795下一步[39510:607]*由于未捕获的异常“nSinternalinconsistenceexception”终止应用程序,原因:“UITableView数据源必须从tableView返回单元格:cellForRowAtIndexPath:” *第
TablePickerViewController* picker = [[TablePickerViewController alloc] initWithSelectableOptions:options selectedIndex:selectedIndex selectionBlock:selectionBlock];
self.popover2 = nil;
self.popover2 = [[UIPopoverController alloc] initWithContentViewController:picker];
self.popover2.popoverContentSize = CGSizeMake(300, 200);
self.popover2.delegate = self;
picker.popover = self.popover2;
[self.popover2 presentPopoverFromRect:rect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
return picker;
为了澄清,从0,01024768(横向)传递到当前的框架
}
奇怪。如果没有调用
cellForRowAtIndexPath
,我不希望它返回nil时出错。我知道@PhillipMills-虽然正在调用行数,但是如果rows==0,表视图会显示在UI上,所以它不会调用“CellForRow”,因为没有显示“我被难倒了!多年来也在制作表视图!随机任务!”ions:当您说从未调用它时,您使用了断点或NSLog()
为了验证这一点?你在为单元格注册NIB或类方面做了什么创造性的工作吗?IB中的单元格重用标识符和CellIdentint
?PhillipMills在创建单元格方面没有创造性,没有子类化,是的,NSLog从不激发!我在一个单独的项目中编写了或多或少完全相同的代码,我t工作得太完美了,这让我觉得Xcode玩得不好!我清理了所有派生数据等等-(
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellIdentt forIndexPath:indexPath];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentt];
}
cell.accessoryType = UITableViewCellAccessoryNone;
if (self.selectedIndex == indexPath.row) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
cell.textLabel.attributedText = self.options[indexPath.row];
return cell;