在iOS中删除childViewController

时间:2015-08-06 15:03:12

标签: ios uiviewcontroller childviewcontroller

我以这种方式添加了一个ChildViewController,它打开了屏幕的一半。

function parseBinary(str) {
  var i, value = 0;
  for (i = 0; i < str.length; ++i)
    value = value * 2 + +str[i];
  return value;
}

关于ChildView的解雇我叫这个:

   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];

所以我有两个按钮,按钮1和按钮2,当用户点击按钮1时,一个childView从底部动画显示。现在,如果用户按下按钮2,则解除之前的childView,然后显示新的childView

所以问题是如果我非常快地点击两个按钮,比如播放一个casio,那么childViews会重叠。

1)我们如何解决这个问题。

2)我是否正确地做了

此致 兰吉特

1 个答案:

答案 0 :(得分:0)

尝试在动画播放过程中暂时禁用按钮2:

   [button2 setEnabled:NO]

然后在动画结束时将其反转:

  [button2 setEnabled:YES]