ios - 使用 iOS 7 滑动导航时导航栏故障

标签 ios objective-c iphone xcode uinavigationcontroller

当我使用滑动返回上一个 View 时,我的应用程序出现奇怪的图形故障。

当我正常滑动并完成滑动手势时,一切正常。

当我取消滑动手势时,即:开始手势然后向相反方向移动手指以停止手势并停留在当前 View 。

我遇到的故障如果我返回到上一个屏幕,该 View 的栏按钮项目将与上一个 View 的栏按钮项目重叠。

截图: 起点:enter image description here

向后滑动手势和完成手势,转到上一个 View ,工作正常:enter image description here

滑动返回手势和取消手势,从而停留在当前屏幕,然后返回上一屏幕,文本按钮重叠:enter image description here

此图形故障仅在强制退出应用程序并重新启动时才会消失。但当然,如果您再次引发故障,它会再次出现。

希望有一些开发者遇到同样的问题。

编辑,问题原因如下代码:

- (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/

相关文章:

iphone - MKAnnotationView - 锁定自定义注释 View 以固定位置更新

iphone - 关于 if 和 else 部分在 iPhone sdk 中的导航 Controller 类中的混淆

iphone - 添加手势识别器时 SWRevealViewController 为零

ios - 使用 NSDictionary 元素缓慢创建 NSMutableArray

ios - ARC 中的引用计数

objective-c - 如何使用 NSURLSession 跟踪多次下载?

iphone - 从远程 MySQL 获取记录到 iPhone 的最快最有效的方法

ios - 如何给 CAGradientLayer "locations"

iphone - 如何在我的应用程序中定义自定义键盘?

ios - 如何检查 NSXmlParser 解析完成?