通过滑动详细视图来增加coredata详细信息视图

时间:2013-03-14 17:40:41

标签: ios core-data nsfetchedresultscontroller

我一直试图找到答案。

我有一个coredata表,当我从该表中选择一个实体时,会推送一个包含detailviewcontroller中所有信息的详细视图。

我希望detailview只需刷新时刷新下一个对象的详细信息。有没有人看过这个函数的教程或示例代码?

我已经找到了这个部分教程,但是对于我不知道从哪里开始的部分有很多缺失的解释:http://craigcoded.com/2010/10/05/accessing-nsfetchedresultscontroller-results-on-the-detail-view-of-a-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];

0 个答案:

没有答案