Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
188 views
in Technique[技术] by (71.8m points)

objective c - ios error Assertion failure in -[UICollectionView layoutSublayersOfLayer:] in ios 7

I am using collection view and getting a crash in ios 7 but it's working fine above 7. Getting crash after the line: [self dismissViewControllerAnimated:YES completion:nil];

the error message here:

*** Assertion failure in -[UICollectionView layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2935.137/UIView.m:8794

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UICollectionView's implementation of -layoutSubviews needs to call super.'

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UICollectionView's implementation of -layoutSubviews needs to call super.'

This error has very useful information. Ensure that, in your collection view, you are calling layoutSubviews on super and there is no code after that.

- (void)layoutSubviews {
  // Your Custom Code

  [super layoutSubviews]; // No code after this and this is called last
}

You can try creating a custom UICollectionView and enforcing call to layoutSubviews on super something like this:

@interface MyCollectionView : UICollectionView

@end

@implentation MyCollectionView

- (void)layoutSubviews {
    // Your Custom Code

    [super layoutSubviews];
}

@end

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...