一段时间以来,我一直在努力寻找这个问题的答案。
我有一个 coredata 表,当我从该表中选择一个实体时,会推送一个详细视图,其中包含详细视图控制器中的所有信息。
我希望详细视图在滑动时只刷新下一个对象的详细信息。有没有人看过这个函数的教程或示例代码?
我找到了这个部分教程,但是对于我不知道从哪里开始的部分有很多缺失的解释:http: //craigcoded.com/2010/10/05/accessing-nsfetchedresultscontroller-results-on-the -uitableview的详细视图/
这看起来应该放在 tableViewController 中,而不是 detailViewController 中。
提前致谢。迈克尔
它包括这个递减逻辑:
NSUInteger rowIndex = [[self storyIndex] row];
NSUInteger sectionIndex = [[self storyIndex] section];
if (rowIndex > 0) {
rowIndex--;
} else if (sectionIndex > 0) {
sectionIndex--;
rowIndex = [[[[fetchedResultsController sections] objectAtIndex:sectionIndex] objects] count] - 1;
}
storyIndex = [NSIndexPath indexPathForRow:rowIndex inSection:sectionIndex];
Story *story = [fetchedResultsController objectAtIndexPath:storyIndex];
[self setupToolbarForStory:story];
[storyView setStory:story];
[storyView setNeedsDisplay];
这个增量逻辑:
NSUInteger rowIndex = [[self storyIndex] row];
NSUInteger sectionIndex = [[self storyIndex] section];
if (rowIndex < [[[[fetchedResultsController sections] objectAtIndex:sectionIndex] objects] count] - 1) {
rowIndex++;
} else if (sectionIndex < [[fetchedResultsController sections] count] - 1) {
sectionIndex++;
rowIndex = 0;
}
storyIndex = [NSIndexPath indexPathForRow:rowIndex inSection:sectionIndex];
Story *story = [fetchedResultsController objectAtIndexPath:storyIndex];
[self setupToolbarForStory:story];
[storyView setStory:story];
[storyView setNeedsDisplay];