-layoutSubviews
ランドスケープで別のレイアウトを作成するためにオーバーライドしようとしているという奇妙な問題があります。私の方法は縦向きでは問題なく動作しますが、横向きのサブビューの 1 つに変換を設定すると、次のエラーが発生します。
*** Assertion failure in -[LSSlideNotesView layoutSublayersOfLayer:], /SourceCache/UIKit/UIKit-2380.17/UIView.m:5776
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. LSSlideNotesView's implementation of -layoutSubviews needs to call super.'
私の方法は次のとおりです。
-(void)layoutSubviews {
[super layoutSubviews];
bool horz = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);
if (horz) {
CGRect contentFrame = self.bounds;
contentFrame.size.width -= (notesHeight + 40);
if (contentFrame.size.width < 0) {
contentFrame.size.width = 0;
notesHeight = self.bounds.size.width - 40;
}
slideCarouselView.frame = contentFrame;
remotePointerView.frame = contentFrame;
// ***** This is the offending line *****
notesLabel.transform = CGAffineTransformMakeRotation(-M_PI_2);
// **************************************
notesLabel.bounds = CGRectMake(0, 0, contentFrame.size.height, 40);
notesLabel.center = CGPointMake(CGRectGetMaxX(contentFrame) + 20, contentFrame.size.height / 2);
CGRect notesRect = self.bounds;
notesRect.origin.x = notesRect.size.width - notesHeight;
notesRect.size.width = notesHeight;
notesTextView.frame = notesRect;
labelCopyFail.frame = CGRectMake(contentFrame.size.width / 2 - 65, contentFrame.size.height * 3 / 4 - 20, 130, 30);
} else {
CGRect contentFrame = self.bounds;
contentFrame.size.height -= (notesHeight + 40 + keyboardHeight);
if (contentFrame.size.height < 0) {
contentFrame.size.height = 0;
notesHeight = self.bounds.size.height - keyboardHeight - 40;
}
slideCarouselView.frame = contentFrame;
remotePointerView.frame = contentFrame;
notesLabel.transform = CGAffineTransformIdentity;
notesLabel.frame = CGRectMake(CGRectGetMinX(contentFrame), CGRectGetMaxY(contentFrame), contentFrame.size.width, 40);
CGRect notesRect = self.bounds;
notesRect.origin.y = notesRect.size.height - notesHeight - keyboardHeight;
notesRect.size.height = notesHeight;
notesTextView.frame = notesRect;
labelCopyFail.frame = CGRectMake(contentFrame.size.width / 2 - 65, contentFrame.size.height * 3 / 4 - 20, 130, 30);
}
}
その行をコメントアウトすると、エラーは発生しません。なぜこれが起こるのか誰か知っていますか?何か不足していますか?私は自分のアプリの他の場所でほぼこの正確な変換を行いましたが、問題なく動作します。私は一生、ここで何が起こっているのか理解できません。私はほとんど何でも試してみたいと思っています。