のサブビューの1つをアニメートし、UIWindowそれをUIWindow使用から削除するメソッドがありremoveFromSuperviewます。しかし、removeFromSuperviewアニメーションブロックの後に置くと、アニメーションが再生される前にからが削除されるため、アニメーションが表示さremoveFromSuperviewれません:-(アニメーションが最初に再生されてからサブビューが削除されるように遅延するにはどうすればよいですか?アニメーションブロックの後に試しましたが、表示されませんでしたアニメーションも何らかの理由でスリープするため、望ましい効果があります。UIViewUIWindowremoveFromSuperview[NSThread sleepForTimeInterval:1];
このメソッドの私のコード:
- (void) animateAndRemove
{
NSObject *mainWindow = [[UIApplication sharedApplication] keyWindow];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.8];
UIView *theView = nil;
for (UIView *currentView in [mainWindow subviews])
{
if (currentView.tag == 666)
{
currentView.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:0.0];
theView = currentView;
}
}
[UIView setAnimationTransition: UIViewAnimationTransitionNone forView:theView cache:YES];
[UIView commitAnimations];
//[NSThread sleepForTimeInterval:1];
[theView removeFromSuperview];
}