0
アニメーションのブロックでlayoutIfNeededを呼び出すと、同じ問題が発生しましたか?アニメーションブロックでレイアウトを呼び出すと、iPhone 7のUIがフリーズする
私は方法があります:
- (void)hide {
dispatch_block_t onMain = ^{
CGFloat height = -viewContent.frame.size.height;
[UIView animateKeyframesWithDuration:0.15f delay:0 options:0 animations:^{
[UIView addKeyframeWithRelativeStartTime:0.f relativeDuration:0.7f animations:^{
self.constraintViewContentBottom.constant = height/3;
[self layoutIfNeeded];
}];
[UIView addKeyframeWithRelativeStartTime:0.7f relativeDuration:0.3f animations:^{
self.constraintViewContentBottom.constant = height;
[self layoutIfNeeded];
}];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.2f animations:^{
self.viewBackground.alpha = 0.0f;
}
completion:^(BOOL finished) {
self.hidden = YES;
}];
}];
};
if([NSThread isMainThread]) {
onMain();
}
else {
dispatch_sync(dispatch_get_main_queue(), onMain);
}
}
多くのデバイス上で完璧に動作しますが、1 iPhone 7、ライン上:UIをフリーズ[self layoutIfNeeded];
を。
私はそのデバイスをデバッグできませんが、いくつかのログを取得できます。
誰でも問題を解決できる方法を知っていますか?
ありがとうございました。
基本的に[UIView animateWithDuration:0.2f animations:^ {}]から呼び出すと、方法 - あなたは正しい。しかし、私はさまざまな変種を試みました - 前に、内部 - 結果は同じです。 = – Andrei
そして、あなたは 'dispatch_sync'を使う必要がありますか? –
dispatch_syncを使用しないでください! –