- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个名为 dummyData 的数组,我在将数组注释的计数作为表中的行数返回时遇到问题。
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
NSArray *commentsArray=[[dummyData objectAtIndex:section] valueForKeyPath:@"comments"];
NSLog(@"Comments: %d", [commentsArray count]);
if (section == didSection) {
return [[[dummyData objectAtIndex:section] valueForKeyPath:@"comments"] count];
}
return 0;
}
它给了我这个错误:
由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无效更新:第 0 节中的行数无效。更新 (3) 后现有部分中包含的行数必须等于行数更新前包含在该部分中的 (0),加上或减去从该部分插入或删除的行数(2 插入,0 删除)以及加上或减去移入或移出该部分的行数(0 移入, 0 移出)。'
这是我的数组:
dummyData = [[NSMutableArray alloc] init];
[dummyData addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"http://g-ecx.images-amazon.com/images/G/01/electronics/detail-page/Klipsch-Image-S4-II-Black-Lifestyle.jpg", @"badge.png",@"Got Strike! at", @"Alex Shin",
[NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:@"James", @"30 minutes ago", @"Great Shot!", @"https://c676132.ssl.cf0.rackcdn.com/_84A2468-50cf361795eb2.jpg", nil]
forKeys:
[NSArray arrayWithObjects:@"name", @"dateline", @"body", @"image_url", nil]],
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:@"Kim", @"10 minutes ago", @"I should have seen it.", @"http://3.bp.blogspot.com/-tBFQC9y-ZpM/Tmb8DaeYEmI/AAAAAAAAA9M/TahVx2IiQsE/s400/Bowling+and+Best+Bowling+Player+Shalin+Zulkifli+cover.jpg", nil]
forKeys:
[NSArray arrayWithObjects:@"name", @"dateline", @"body", @"image_url", nil]],
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:@"Matt", @"5 minutes ago", @"Nice", @"http://www.beverlyhillsmagazine.com/wp-content/uploads/Ashton-Kutcher-Hollywood-Stars-Rich-and-Famous-Movie-Stars-Star-of-the-Week-Beverly-Hills-Magazine-Hollywood-Magazines--300x336.jpg", nil]
forKeys:
[NSArray arrayWithObjects:@"name", @"dateline", @"body", @"image_url", nil]]
, nil] , nil]
forKeys:[NSArray arrayWithObjects:@"photo", @"credit",@"credit_label", @"name", @"comments", nil]
]];
[dummyData addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"http://g-ecx.images-amazon.com/images/G/01/electronics/detail-page/Klipsch-Image-S4-II-Black-Lifestyle.jpg", @"location_icon.png",@"Checked in at", @"Jessah Ouano",
[NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:@"Matt", @"1 hour ago", @"Welcome!", @"http://www.beverlyhillsmagazine.com/wp-content/uploads/Ashton-Kutcher-Hollywood-Stars-Rich-and-Famous-Movie-Stars-Star-of-the-Week-Beverly-Hills-Magazine-Hollywood-Magazines--300x336.jpg", nil]
forKeys:
[NSArray arrayWithObjects:@"name", @"dateline", @"body", @"image_url", nil]],
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:@"Steve", @"47 minutes ago", @"You'll enjoy here.", @"http://www.oozyleaks.com/wp-content/uploads/2013/09/Taylor-Lautner.jpg", nil]
forKeys:
[NSArray arrayWithObjects:@"name", @"dateline", @"body", @"image_url", nil]]
, nil] , nil]
forKeys:[NSArray arrayWithObjects:@"photo", @"credit",@"credit_label", @"name", @"comments", nil]
]];
[dummyData addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"http://g-ecx.images-amazon.com/images/G/01/electronics/detail-page/Klipsch-Image-S4-II-Black-Lifestyle.jpg", @"location_icon.png",@"Checked in at", @"Richard Son",
[NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:@"Pinky", @"3 hours ago", @"I saw it", @"http://g-ecx.images-amazon.com/images/G/01/electronics/detail-page/Klipsch-Image-S4-II-Black-Lifestyle.jpg", nil]
forKeys:
[NSArray arrayWithObjects:@"name", @"dateline", @"body", @"image_url", nil]],
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:@"Tom", @"1 hour ago", @"realy?", @"http://g-ecx.images-amazon.com/images/G/01/electronics/detail-page/Klipsch-Image-S4-II-Black-Lifestyle.jpg", nil]
forKeys:
[NSArray arrayWithObjects:@"name", @"dateline", @"body", @"image_url", nil]],
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:@"Caty", @"11 minutes ago", @"yes", @"http://g-ecx.images-amazon.com/images/G/01/electronics/detail-page/Klipsch-Image-S4-II-Black-Lifestyle.jpg", nil]
forKeys:
[NSArray arrayWithObjects:@"name", @"dateline", @"body", @"image_url", nil]]
, nil] , nil]
forKeys:[NSArray arrayWithObjects:@"photo", @"credit",@"credit_label", @"name", @"comments", nil]
]];
[dummyData addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"http://g-ecx.images-amazon.com/images/G/01/electronics/detail-page/Klipsch-Image-S4-II-Black-Lifestyle.jpg", @"badge.png",@"Got a Strike! at", @"Dexter Dulay",
[NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:@"Matt", @"12 minutes ago", @"Take the opportunity", @"http://g-ecx.images-amazon.com/images/G/01/electronics/detail-page/Klipsch-Image-S4-II-Black-Lifestyle.jpg", nil]
forKeys:
[NSArray arrayWithObjects:@"name", @"dateline", @"body", @"image_url", nil]],
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:@"Dex", @"11 minutes ago", @"Maybe later", @"http://g-ecx.images-amazon.com/images/G/01/electronics/detail-page/Klipsch-Image-S4-II-Black-Lifestyle.jpg", nil]
forKeys:
[NSArray arrayWithObjects:@"name", @"dateline", @"body", @"image_url", nil]],
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:@"Drew", @"9 minutes ago", @"Alex should win", @"http://g-ecx.images-amazon.com/images/G/01/electronics/detail-page/Klipsch-Image-S4-II-Black-Lifestyle.jpg", nil]
forKeys:
[NSArray arrayWithObjects:@"name", @"dateline", @"body", @"image_url", nil]],
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:@"Alex", @"9 minutes ago", @"As always. :)", @"http://g-ecx.images-amazon.com/images/G/01/electronics/detail-page/Klipsch-Image-S4-II-Black-Lifestyle.jpg", nil]
forKeys:
[NSArray arrayWithObjects:@"name", @"dateline", @"body", @"image_url", nil]],
[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:@"Luis", @"2 minutes ago", @":D", @"http://g-ecx.images-amazon.com/images/G/01/electronics/detail-page/Klipsch-Image-S4-II-Black-Lifestyle.jpg", nil]
forKeys:
[NSArray arrayWithObjects:@"name", @"dateline", @"body", @"image_url", nil]]
, nil] , nil]
forKeys:[NSArray arrayWithObjects:@"photo", @"credit",@"credit_label", @"name", @"comments", nil]
]];
我的问题是,如何返回每个部分的评论数。因为评论数组有不同数量的内容或计数。
最佳答案
解决了问题:
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
NSArray *commentsArray=[[dummyData objectAtIndex:section] valueForKeyPath:@"comments"];
NSLog(@"Comments: %d", [commentsArray count]);
if (section == didSection) {
return [[[dummyData objectAtIndex:section] valueForKeyPath:@"comments"] count];
}
return 0;
关于ios - NSInternalInconsistencyException 原因 : 'Invalid update: invalid number of rows in section 0' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24401323/
这个问题在这里已经有了答案: Multi level categories with items on all levels in UITableView (1 个回答) 关闭 6 年前。 标题说明
我想在编译时从代码中删除未使用的函数。然后我写一些代码(main.c): #include const char *get1(); int main() { puts( get1() );
升级到 Xcode 4.4 后,当我尝试在 iPhone 或 iPad 上运行我的(通用)应用程序时,我遇到了这个烦人的链接器错误。如果我在 iOS 模拟器上运行它,我没有问题... 我尝试添加 ar
我以前从未见过这个错误,我搜索了它可能发生的原因,但找不到任何相关信息: CoreData: error: Serious application error. An exception was ca
我正在使用以下内容填充 UITableView 部分的各个部分: fetchedResultsController = NSFetchedResultsController(fetchReques
是标签允许包含在另一个 中标签?它会在 HTML5 中验证吗? 最佳答案 Yes ! w3 鼓励您在分节内容的元素中显式包装节,而不是依赖于在分节内容的一个元素中包含多个标题而生成的隐式节,并且允许
我使用部分来确定页面的不同部分。这些部分的底部边距为 90px,但是当在页面中创建/放置 ID 为“clients-full”的部分时,我希望出现在它之前/上方的任何部分的底部边距为 0。我可以做吗这
我现在有一个第三方提供的c静态库(用arm-gcc编译的)。我不可能(让第三方)重新编译库。 在调查库内容时,我发现 gcc 选项 -ffunction-sections 和 -fdata-secti
大家好,我陷入了一个奇怪的问题,我正在重新加载 tableViewSection,它正在正确地重新加载该部分,但它隐藏了其他部分,直到我向上或向下滚动它。我使用以下代码重新加载 func tabl
在我的项目中,我有扩展 ArrayAdapter 的类并实现 SectionIndexer .实现方法时getPositionForSection和 getSectionForPosition我发现了
我正在尝试编译 scss,以便在它具有 class1 时获得该部分。我不知道如何去做,因为我得到了空间,而且它的工作方式不一样。 当前输出: .class2 > section .class1 {
我正在阅读 Mark Pilgirm 的“Dive into HTML5”和 semantics section ,它讨论了 HTML5 如何引入 和 元素。它说 s 代表通用文档或部分,而 s
我是使用ARM编译器进行Keil Microvision V5.12编程的新手。 我无法编译一个简单的组装项目,但出现此错误: .\Objects\learn.sct(7): error: L6236
这是我第一次在这里问问题,但我不得不说这个网站在过去几个月里给了我巨大的帮助(iphone-dev-wise),我为此表示感谢。 但是,我没有找到解决这个问题的方法:我有一个包含 2 个部分的 UIT
我在 IOS 中实现了一个 TableView (4 个部分)。问题是我刚刚在第一部分添加了一个部分标题。其他部分没有标题。第一部分没有行(行数为 0)。其他部分有多行。当我滚动时,第一部分的标题不粘
我有一个包含多个部分的表格 View 。我希望能够将行从一个部分移动到另一个部分,并在没有行时删除一个部分。我正在尝试通过 moveRowAtIndexPath 执行此操作,但我的代码不起作用并抛出
我正在尝试删除不符合 for 循环条件的行。但是,我收到错误消息:“尝试从第 1 部分删除第 0 行,但更新前只有 1 个部分。”我以前从未见过这个,也不确定为什么会收到它。 我的代码: func
GCC 页面中针对功能部分和数据部分选项的以下内容: -ffunction-sections -fdata-sections Place each function or data item into
我想在安装新数据库之前删除旧数据库,以便为用户更新它。 我有以下情况: 在我的 Components 部分中,我为用户提供了一个选项: [Components] Name: "updateDataba
我从工作区添加了一个测试用例。可能已经一周了,所以我不记得它是来自 Backlog 还是来自董事会。 现在,当我进入测试/测试计划时,它没有出现。我找不到将其添加到测试套件的方法。 我可以通过测试区域
我是一名优秀的程序员,十分优秀!