【问题标题】:Can't remove subview from superview-Xcode6无法从 superview-Xcode6 中删除子视图
【发布时间】:2015-02-21 07:01:56
【问题描述】:

我通过 Storyboard 向超级视图添加了一个视图 (displayTapeView),它工作正常。但是当我想在单击 displayTapeView 上的“返回”按钮时删除 displayTapeView。它不起作用。我目前的代码如下:

- (IBAction)tapeButtonPressed:(id)sender {
self.displayTapeView.hidden=NO;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
//[[self displayTapeView] removeFromSuperview];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.displayTapeView cache:YES];
self.displayTapeView.layer.masksToBounds=NO;
self.displayTapeView.layer.shadowOffset=CGSizeMake(-15.0,20.0);
self.displayTapeView.layer.shadowRadius=5.0;
self.displayTapeView.layer.shadowOpacity=0.5;
//[[self view] addSubview:_displayTapeView];
[UIView commitAnimations];
}

- (IBAction)backButtonPressed:(id)sender {
[[self displayTapeView] removeFromSuperview];

}

我想要做的是当单击“返回”按钮时,displayTapeView 被删除并显示超级视图。

提前谢谢你!

【问题讨论】:

  • 尝试隐藏视图而不是删除它。我猜你的目的就可以解决了。

标签: objective-c addsubview superview


【解决方案1】:
self.displayTapeView.hidden = YES;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-09
    相关资源
    最近更新 更多