在 - [UITableView _endCellAnimationsWithContext:]中引发失败 [英] Assertion failure in -[UITableView _endCellAnimationsWithContext:]

查看:2807
本文介绍了在 - [UITableView _endCellAnimationsWithContext:]中引发失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望这将是一个快速修复。我一直在努力弄清楚我不断得到的错误。



感谢

p>


2012-04-12 21:11:52.669 Chanda [75100:f803] ---在 UITableView _endCellAnimationsWithContext:] /SourceCache/UIKit_Sim/UIKit-1914.84/UITableView.m:1037
2012-04-12 21: 11:52.671 Chanda [75100:f803] ---由于未捕获异常而终止应用程序 NSInternalInconsistencyException ',原因:无效的更新:更新(2)后现有节中包含的行数必须等于更新前节(2)中包含的行数,加上或减去从该节插入或删除的行数(插入1个, 0删除),并加或减了移入或移出该部分的行数(0移入,0移出)。




  #importAppDelegate.h

@implementation AppDelegate

@synthesize window = _window;
@synthesize databaseName,databasePath;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.databaseName = @Customers.db;

NSArray * documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString * documentDir = [documentPaths objectAtIndex:0];
self.databasePath = [documentDir stringByAppendingPathComponent:self.databaseName];
[self createAndCheckDatabase];

return YES;
}

- (void)createAndCheckDatabase {
BOOL success;

NSFileManager * fileManager = [NSFileManager defaultManager];
success = [fileManager fileExistsAtPath:databasePath];

if(success)return;

NSString * databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:self.databaseName];

[fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil];
}

@end


解决方案>

我看不到你向我们展示这部分代码的原因。您的错误必须在代码中连接到此部分我假设

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

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


$ b b

可能你在这些数据源方法中犯了一个错误。目前不可能说出究竟是什么错误,但我认为可能是这样的:你在 numberOfRowsInSection 中告诉表格视图,你想有 n rows保留并设置,并在 cellForRowAtIndexPath 中,则只处理 n-1 行。



对不起,这个答案不能像它应该的那样精确。如果你向我们展示你的数据源的实现,那么很容易分辨出发生了什么。


Hopefully this will be a quick fix. I have been trying to figure out the error that i keep getting. The error is listed below and the appdelagate is below that.

Any help is appreciated.

Thanks

2012-04-12 21:11:52.669 Chanda[75100:f803] --- Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1914.84/UITableView.m:1037 2012-04-12 21:11:52.671 Chanda[75100:f803] --- Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (2), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'

#import "AppDelegate.h"

@implementation AppDelegate

@synthesize window = _window;
@synthesize databaseName,databasePath; 

- (BOOL)application: (UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions {
    self.databaseName = @"Customers.db";

    NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentDir = [documentPaths objectAtIndex:0];
    self.databasePath = [documentDir stringByAppendingPathComponent:self.databaseName];
    [self createAndCheckDatabase];

    return YES;
}

- (void)createAndCheckDatabase {
    BOOL success;

    NSFileManager *fileManager = [NSFileManager defaultManager];
    success = [fileManager fileExistsAtPath:databasePath];

    if (success) return; 

    NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:self.databaseName];

    [fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil];
}

@end

解决方案

I don't see the reason for you to show us this part of code. Your error must be connected to this part in your code I assume

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

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

Probably you are making a mistake in one of these data source methods. Currently it's impossible to say what exactly is wrong but I assume it could be something like: You are telling the table view in the numberOfRowsInSection you would like to have n rows reserved and setup and in the cellForRowAtIndexPath you then only handle n - 1 rows for example.

Sorry that this answer can't be as precise as it should be. If you show us your implementation of your data source it would be much easier to tell what's going on.

这篇关于在 - [UITableView _endCellAnimationsWithContext:]中引发失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆