単一のメソッドからビューを非表示および表示しようとしていますが、表示および非表示に機能するはずですが、その瞬間です。
- (void)toggleMyView:(BOOL)show
{
CGRect orig = self.originalMyViewFrame; // original frame of the view
CGRect offScreen = CGRectMake(orig.origin.x, self.view.frame.size.height, orig.size.width, orig.size.height);
if (show) {
self.myView.frame = offScreen; // set off screen
self.myView.hidden = NO; // unide the view
[UIView animateWithDuration:0.5 animations:^{
self.myView.frame = orig; // animate to original position
}];
} else {
[UIView animateWithDuration:0.3 animations:^{
self.myView.frame = offScreen; // animate off screen
} completion:^(BOOL finished) {
self.myView.hidden = YES; // hide when animation finished
}];
}
}
非表示ロジックを削除すると、うまくアニメーション化されます。
- (void)toggleMyView:(BOOL)show
{
CGRect orig = self.originalMyViewFrame; // original frame of the view
CGRect offScreen = CGRectMake(orig.origin.x, self.view.frame.size.height, orig.size.width, orig.size.height);
if (show) {
self.myView.frame = offScreen; // set off screen
self.myView.hidden = NO; // unide the view
[UIView animateWithDuration:0.5 animations:^{
self.myView.frame = orig; // animate to original position
}];
} else {
self.myView.hidden = YES; // hide when animation finished
}
}
非表示ロジックを追加すると壊れる理由がわかりません。
これはメモリ保持サイクルの問題でしょうか?