美文网首页
Exception集合

Exception集合

作者: 喵喵粉 | 来源:发表于2020-02-26 14:52 被阅读0次
  1. 刷新collectionviewcrash

reason: 'UICollectionView received layout attributes for a cell with an index path that does not exist: <NSIndexPath: 0xc000000000200016> {length = 2, path = 0 - 1}'

解决:
reloadData之后将当前的布局设置失效invalidateLayout,则collectionView会重新刷新布局,否则就会沿用旧的布局导致获取不到数据,导致崩溃。

collectionView.reloadData()
collectionView.collectionViewLayout.invalidateLayout()
  1. 10.*系统下collectionview crash

*** Assertion failure in -[_UIFlowLayoutSection computeLayoutInRect:forSection:invalidating:invalidationContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.7.47/UIFlowLayoutSupport.m:823
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionViewFlowLayout internal error'
*** First throw call stack:
(
0 CoreFoundation 0x0000000106c11b0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000106676141 objc_exception_throw + 48
2 CoreFoundation 0x0000000106c15cf2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000103535536 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x000000010508ef1b -[_UIFlowLayoutSection computeLayoutInRect:forSection:invalidating:invalidationContext:] + 13308
5 UIKit 0x0000000105024f11 __76-[UICollectionViewFlowLayout _updateItemsLayoutForRect:allowsPartialUpdate:]_block_invoke + 533
6 CoreFoundation 0x0000000106ba2652 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 114

解决:
在布局生效前调用invalidateLayout

override func viewWillLayoutSubviews() {
    super.viewWillLayoutSubviews()
    collectionView.collectionViewLayout.invalidateLayout()
}

相关文章

  • Exception集合

    刷新collectionviewcrash reason: 'UICollectionView received ...

  • JAVA语言中泛型、Set和异常处理Exception汇总

    一、目的 1、掌握Java语言中泛型的定义和使用,2、同时加强对集合的使用,3、掌握Exception的相关知识,...

  • Azalea\Exception

    Exception 异常虚类 Azalea\Exception 继承于 PHP 异常类 \Exception Ex...

  • Frist Android

    Exception Exception: ActivityNotFoundException 启动browser 标签

  • 2017-6-1

    ◉ exception 和 import*○ exception1.exception 作为所有异常的父类,多了 ...

  • Exception

    checked exception and unchecked exception checked excepti...

  • Exception

    Throwable-->Exception/Error Exception除了runtimeException及其...

  • android 快速定位调用栈方式

    在一个方法里加入exception 并打印调用栈信息 Exception e = new Exception("A...

  • C++异常

    异常处理 头文件中定义了异常类exception和bad_exception,异常类exce...

  • Java 打印堆栈的方法

    方法一. Exception e = new Exception("this is a log"); //相应的...

网友评论

      本文标题:Exception集合

      本文链接:https://www.haomeiwen.com/subject/qssvchtx.html