【问题标题】:iOS 'NSInternalInconsistencyException', reason: 'UICollectionViewFlowLayout internal erroriOS 'NSInternalInconsistencyException',原因:'UICollectionViewFlowLayout 内部错误
【发布时间】:2017-01-23 09:00:02
【问题描述】:

我在自调整大小的 tableview 中有一个集合视图。当用户点击集合视图时,我会呈现另一个视图。

我仍然可以纵向显示该视图。但是当我旋转到横向时,我收到了这个错误并崩溃了。我该怎么办?

2017-01-23 16:52:16.448417 SWEET Mini[1638:647130] * 断言 -[_UIFlowLayoutSection 失败 computeLayoutInRect:forSection:invalidating:invalidationContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3600.6.22/UIFlowLayoutSupport.m:823 2017-01-23 16:52:16.451537 SWEET Mini[1638:647130] * 终止应用 由于未捕获的异常“NSInternalInconsistencyException”,原因: 'UICollectionViewFlowLayout 内部错误'

我只是提出另一个这样的观点。

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
    browser.zoomPhotosToFill = NO;
    [browser setCurrentPhotoIndex:(indexPath.row)];
    browser.enableSwipeToDismiss = YES;
    UINavigationController *browseNav = [[UINavigationController alloc] initWithRootViewController:browser];

    if ([[AppDelegate instance].window.rootViewController isKindOfClass:[UINavigationController class]])
    {
        UINavigationController *nav = (UINavigationController *) [AppDelegate instance].window.rootViewController;
        [nav presentViewController:browseNav animated:YES completion:nil];
    }
    else if ([[AppDelegate instance].window.rootViewController isKindOfClass:[UITabBarController class]]) {
        UITabBarController *tab = (UITabBarController *) [AppDelegate instance].window.rootViewController;
        [tab presentViewController:browseNav animated:YES completion:nil];
    }
}

【问题讨论】:

  • 也许您的视图层次结构已损坏?为什么你不使用 [self presentViewController:browseNav animated:YES completion:nil];介绍另一个 vc 吗?
  • 因为我已经在 NSObject 中编写了该代码,它与 uiviewcontroller 相去甚远。 (我的意思是我仍然可以与代表一起推动)
  • 你试过委托吗?问题仍然存在?
  • 您可以在这个答案中找到帮助:stackoverflow.com/a/44467194/584405。本质上就是在viewcontroller的viewWillLayoutSubviews中调用collectionView.collectionViewLayout.invalidateLayout()

标签: ios objective-c


【解决方案1】:

我遇到了同样的错误信息。事实证明,它只发生在模拟器上,在真实设备上一切正常。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-16
  • 1970-01-01
  • 1970-01-01
  • 2014-05-25
  • 2020-05-22
相关资源
最近更新 更多