我得到的错误:
Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-3347.44.2.2/UITableView.m:1326
2015-10-26 11:38:49.473 huwai[1784:684487] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete row 0 from section 1, but there are only 1 sections before the update'
*** First throw call stack:
(0x2a94f0d7 0x390cec77 0x2a94efad 0x2b64fbc9 0x2e1771d7 0xe865f 0xe61db 0x2e12d9ef 0x2dfdcb1d 0x2e3f6811 0x2dfa5ad5 0x2dfa3a4f 0x2dfdaeed 0x2dfda7dd 0x2dfb09b5 0x2e2270ff 0x2dfaf3b7 0x2a91500f 0x2a914423 0x2a912aa1 0x2a85e6d1 0x2a85e4e3 0x321fa1a9 0x2e010445 0x11f44d 0x3969caaf)
libc++abi.dylib: terminating with uncaught exception of type NSException
2.当这个错误发生时意味着,我正在从数组中删除值并再次重新加载 TableView ,在特定时间发生的错误并非总是发生,有时它会发生。
这是我的代码
我在这里创建第三方表格 View
-(void)viewWillLayoutSubviews
{
if([[UIDevice currentDevice].model hasPrefix:@"iPad"])
{
self.mTableView = [[TQMultistageTableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.viewsub.frame.size.height)];
}
else if([[UIDevice currentDevice].model hasPrefix:@"iPhone"])
{
self.mTableView =[[TQMultistageTableView alloc] initWithFrame:CGRectMake(0, 0, self.viewsub.frame.size.width,self.viewsub.frame.size.height)];
}
self.mTableView.delegate = self;
self.mTableView.dataSource = self;
self.mTableView.clipsToBounds=YES;
self.mTableView.tableView.clipsToBounds=YES;
}
- (NSInteger)numberOfSectionsInTableView:(TQMultistageTableView *)tableView
{
return [arrOrder count];
}
- (NSInteger)mTableView:(TQMultistageTableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
#pragma mark row
- (UITableViewCell *)mTableView:(TQMultistageTableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ServiceChargeCell *cell;
cell = [[ServiceChargeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell" forIndexPath:indexPath];
NSLog(@"inside charge screen product array%@",arrOrder);
NSInteger order=[productid integerValue];
NSMutableDictionary *dic=[flow.dicOrder objectForKey:@(order)];
cell.lblname.textColor=[UIColor whiteColor];
cell.lblname.text=[NSString stringWithFormat:@"%@",[dic objectForKey:@"description"]];
NSLog(@"this is lable name=%@",[NSString stringWithFormat:@"%@",[dic objectForKey:@"description"]]);
NSLog(@"this is from label=%@",cell.lblname.text);
return cell;
}
- (UIView *)mTableView:(TQMultistageTableView *)tableView openCellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, tableView.bounds.size.width)];
view.backgroundColor = [UIColor colorWithRed:187/255.0 green:206/255.0 blue:190/255.0 alpha:1];;
return view;
}
#pragma mark - Table view delegate
- (CGFloat)mTableView:(TQMultistageTableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if([[UIDevice currentDevice].model hasPrefix:@"iPhone"])
{
return 40;
}
else
{
return 80;
}
}
- (CGFloat)mTableView:(TQMultistageTableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if([[UIDevice currentDevice].model hasPrefix:@"iPhone"])
{
return 50;
}
else
{
return 50;
}
}
在我的标题 View 中,我有一个按钮,而该按钮的点击操作正在删除一些数据,我再次在此处重新加载表格 View 。
-(void)btnClick:(UIButton *)click
{
if(click.selected==NO)
{
NSString *tag=[NSString stringWithFormat:@"%lu",(long)click.tag];
int key=[tag intValue];
NSMutableDictionary *dic=[flow.dicOrder objectForKey:@(key)];
[flow removeOrder:dic];
}
[self.mTableView.tableView reloadData];
}
为什么在重新加载 tableview 时会出现这种错误?请任何人帮助我解决这个问题
最佳答案
我查看了 TQMultistageTableView,显然在点击 headerView 时,它包含用于删除或插入部分的逻辑。我不确定第三方的工作原理,但似乎在您修改数据后,第三方 tableView 出现某种数据不匹配,并尝试删除不存在的行。
关于ios - 重新加载 tableview 时发生断言失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33339602/
鉴于我有以下迁移:Sequel.migrationdoupdoalter_table:usersdoadd_column:is_admin,:default=>falseend#SequelrunsaDESCRIBEtablestatement,whenthemodelisloaded.#Atthispoint,itdoesnotknowthatusershaveais_adminflag.#Soitfails.@user=User.find(:email=>"admin@fancy-startup.example")@user.is_admin=true@user.save!ende
我正在使用active_admin,我在Rails3应用程序的应用程序中有一个目录管理,其中包含模型和页面的声明。时不时地我也有一个类,当那个类有一个常量时,就像这样:classFooBAR="bar"end然后,我在每个必须在我的Rails应用程序中重新加载一些代码的请求中收到此警告:/Users/pupeno/helloworld/app/admin/billing.rb:12:warning:alreadyinitializedconstantBAR知道发生了什么以及如何避免这些警告吗? 最佳答案 在纯Ruby中:classA
我收到这个错误:RuntimeError(自动加载常量Apps时检测到循环依赖当我使用多线程时。下面是我的代码。为什么会这样?我尝试多线程的原因是因为我正在编写一个HTML抓取应用程序。对Nokogiri::HTML(open())的调用是一个同步阻塞调用,需要1秒才能返回,我有100,000多个页面要访问,所以我试图运行多个线程来解决这个问题。有更好的方法吗?classToolsController0)app.website=array.join(',')putsapp.websiteelseapp.website="NONE"endapp.saveapps=Apps.order("
我已经构建了一些serverspec代码来在多个主机上运行一组测试。问题是当任何测试失败时,测试会在当前主机停止。即使测试失败,我也希望它继续在所有主机上运行。Rakefile:namespace:specdotask:all=>hosts.map{|h|'spec:'+h.split('.')[0]}hosts.eachdo|host|begindesc"Runserverspecto#{host}"RSpec::Core::RakeTask.new(host)do|t|ENV['TARGET_HOST']=hostt.pattern="spec/cfengine3/*_spec.r
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下
我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的
我早就知道Ruby中的“常量”(即大写的变量名)不是真正常量。与其他编程语言一样,对对象的引用是唯一存储在变量/常量中的东西。(侧边栏:Ruby确实具有“卡住”引用对象不被修改的功能,据我所知,许多其他语言都没有提供这种功能。)所以这是我的问题:当您将一个值重新分配给常量时,您会收到如下警告:>>FOO='bar'=>"bar">>FOO='baz'(irb):2:warning:alreadyinitializedconstantFOO=>"baz"有没有办法强制Ruby抛出异常而不是打印警告?很难弄清楚为什么有时会发生重新分配。 最佳答案
我一直致力于让我们的Rails2.3.8应用程序在JRuby下正确运行。一切正常,直到我启用config.threadsafe!以实现JRuby提供的并发性。这导致lib/中的模块和类不再自动加载。使用config.threadsafe!启用:$rubyscript/runner-eproduction'pSim::Sim200Provisioner'/Users/amchale/.rvm/gems/jruby-1.5.1@web-services/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:105:in`co
在启用Rack::Deflater来gzip我的响应主体时偶然发现了一些奇怪的东西。也许我遗漏了一些东西,但启用此功能后,响应被压缩,但是资源的ETag在每个请求上都会发生变化。这会强制应用程序每次都响应,而不是发送304。这在没有启用Rack::Deflater的情况下有效,我已经验证页面源没有改变。我正在运行一个使用thin作为Web服务器的Rails应用程序。Gemfile.lockhttps://gist.github.com/2510816有没有什么方法可以让我从Rack中间件获得更多的输出,这样我就可以看到发生了什么?提前致谢。 最佳答案
我们目前正在为ROR3.2开发自定义cms引擎。在这个过程中,我们希望成为我们的rails应用程序中的一等公民的几个类类型起源,这意味着它们应该驻留在应用程序的app文件夹下,它是插件。目前我们有以下类型:数据源数据类型查看我在app文件夹下创建了多个目录来保存这些:应用/数据源应用/数据类型应用/View更多类型将随之而来,我有点担心应用程序文件夹被这么多目录污染。因此,我想将它们移动到一个子目录/模块中,该子目录/模块包含cms定义的所有类型。所有类都应位于MyCms命名空间内,目录布局应如下所示:应用程序/my_cms/data_source应用程序/my_cms/data_ty