我用这种方式添加了一个ChildViewController,它打开屏幕的一半。
m_customStartupView = [[CustomStartUpViewController alloc]init];
m_customStartupView.delegate = self;
if(m_showStatus == SHOW_STATUS)
{
m_customStartupView.dialogToShow = LAST_SYNC_STATUS;
}
[self addChildViewController:m_customStartupView];
[[self view] addSubview:[m_customStartupView view]];
[m_customStartupView didMoveToParentViewController:self];
CGRect rect = m_customStartupView.view.frame;
if(IPHONE_5)
{
rect.origin.y = 568;
}
else
{
rect.origin.y = 480;
}
m_customStartupView.view.frame = rect;
[UIView beginAnimations:@"ShowView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.2];
if(IPHONE_5)
{
rect.origin.y = 520;
}
else
{
rect.origin.y = 420;
}
m_customStartupView.view.frame = rect;
[UIView commitAnimations];
在ChildView的解散时,我调用这个:
-(void)dismissStartupAlertView:(BOOL)buttonClicked
{
CGRect rect = m_customStartupView.view.frame;
if(IPHONE_5)
{
rect.origin.y = 520
}
else
{
rect.origin.y = 420
}
m_customStartupView.view.frame = rect;
[UIView beginAnimations:@"ShowView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
if(IPHONE_5)
{
rect.origin.y = 568;
}
else
{
rect.origin.y = 480;
}
m_customStartupView.view.frame = rect;
[UIView commitAnimations];
}
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
if([animationID isEqualToString:@"ShowView"])
{
[m_customStartupView willMoveToParentViewController:nil];
[m_customStartupView.view removeFromSuperview];
[m_customStartupView removeFromParentViewController];
}
}
我有两个按钮,Button 1和Button 2,当用户点击button1时,childView会从底部动画出来,然后显示出来。现在如果用户按下按钮2,那么之前的childView将被取消,然后显示新的childView
所以问题是,如果我快速点击两个按钮,就像玩卡西欧一样,那么childViews就会重叠。
我们如何解决这个问题?
2)我做的是否正确
的问候Ranjit
尝试在动画播放时暂时禁用按钮2:
[button2 setEnabled:NO]
然后在动画完成后反转:
[button2 setEnabled:YES]