当我使用滑动返回上一个 View 时,我的应用程序出现奇怪的图形故障。
当我正常滑动并完成滑动手势时,一切正常。
当我取消滑动手势时,即:开始手势然后向相反方向移动手指以停止手势并停留在当前 View 。
我遇到的故障如果我返回到上一个屏幕,该 View 的栏按钮项目将与上一个 View 的栏按钮项目重叠。
截图: 起点:
向后滑动手势和完成手势,转到上一个 View ,工作正常:
滑动返回手势和取消手势,从而停留在当前屏幕,然后返回上一屏幕,文本按钮重叠:
此图形故障仅在强制退出应用程序并重新启动时才会消失。但当然,如果您再次引发故障,它会再次出现。
希望有一些开发者遇到同样的问题。
编辑,问题原因如下代码:
- (void)resetCacheAndRefreshTableAnimated:(BOOL)animated {
[NSFetchedResultsController deleteCacheWithName:kCDFollowedCacheName];
[self setSortDescriptorsForFetchRequest:self.fetchedResultsController.fetchRequest];
NSError *error = nil;
[self.fetchedResultsController performFetch:&error];
[self.tableView reloadData];
}
此方法在 ViewWillAppear 中调用。删除方法调用后,问题就消失了。有什么想法吗?
最佳答案
根据 Vikram 的回复和 StackOverflow 的另一个问题设法弄清楚了。
所以问题是 [self.tableView reloadData]
在 ViewWillAppear
中被调用了。
但是取消滑动时不应重新加载 tableview。
此代码可防止在取消滑动时重新加载:
id <UIViewControllerTransitionCoordinator> tc = self.transitionCoordinator;
if (tc && [tc initiallyInteractive])
{
[tc notifyWhenInteractionEndsUsingBlock:
^(id<UIViewControllerTransitionCoordinatorContext> context)
{
if (![context isCancelled])
// not cancelled, do it
[self resetCacheAndRefreshTableAnimated:YES]; // this will clear the CoreData cache and forces a reload
}];
}
else // not interactive, do it
[self resetCacheAndRefreshTableAnimated:YES]; // this will clear the CoreData cache and forces a reload
关于ios - 使用 iOS 7 滑动导航时导航栏故障,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25701443/