创建UIView可防止发送IBAction

时间:2013-08-07 14:17:36

标签: ios uiview ibaction

我正在尝试将UIView绘制到屏幕上,同时将其他UI元素移出其中。这两个事件都由同一个UISwitch触发。当我不绘制UIView时,UI元素会按原样移动,但是当我调用动画来绘制UIView时,UI元素不会按原样移动。我不知道为什么会这样,任何帮助都非常感谢。

以下是添加和删除视图的功能:

- (IBAction)showHideMyNewView:(UISwitch *)sender {
if (_mySwitch.on) {
    [self.view addSubview:myNewView];
}
else {
    [myNewView removeFromSuperview];
}

这是移动其他UI元素以便为UIView腾出空间的函数:

  - (IBAction)moveUIElementsForPainIntensityView:(id)sender {
_mySwitch = (UISwitch *)sender;
if (_mySwitch.on) {
    [_labelOne moveTo:CGPointMake(50, 350) duration:0.5 option:0];
    [_labelTwo moveTo:CGPointMake(50, 400) duration:0.5 option:0];
    [_labelThree moveTo:CGPointMake(50, 450) duration:0.5 option:0];
    [_labelFour moveTo:CGPointMake(50, 500) duration:0.5 option:0];
}
else {
    [_labelOne moveTo:CGPointMake(50, 150) duration:0.5 option:0];
    [_labelTwo moveTo:CGPointMake(50, 200) duration:0.5 option:0];
    [_labelThree moveTo:CGPointMake(50, 250) duration:0.5 option:0];
    [_labelFour moveTo:CGPointMake(50, 300) duration:0.5 option:0];
}}

0 个答案:

没有答案