-[UITableView _endCellAnimationsWithContext:] 中的断言失败 [英] Assertion failure in -[UITableView _endCellAnimationsWithContext:]

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

问题描述

希望这将是一个快速修复.我一直在试图找出我不断遇到的错误.错误在下面列出,appdelagate 在下面.

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.

感谢任何帮助.

谢谢

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

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

您可能在其中一种数据源方法中犯了错误.目前不可能说出究竟是什么问题,但我认为可能是这样的:您正在告诉 numberOfRowsInSection 中的表视图您希望保留 n 行并且设置并在 cellForRowAtIndexPath 中,然后您只处理 n - 1 行.

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天全站免登陆