[英]RemoveFromSuperView don't work
Although I declared the UIView
in the header file (as below): 尽管我在头文件中声明了
UIView
(如下所示):
IBOutlet UIView *aCustomMsgBoxView;
The RemoveSuperView works in one method but not in the other. RemoveSuperView在一种方法中有效,但在另一种方法中无效。 It works if I put it in this method:
如果我把它放在这种方法中,它将起作用:
-(IBAction)showMsgBox:(id)sender
{
vc = [ViewController sharedInstance].self;
aCustomMsgBoxView = [[UIView alloc] init];
NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"customMsgBox" owner:self options:nil];
aCustomMsgBoxView = [nibObjects objectAtIndex:0];
aCustomMsgBoxView.frame = CGRectMake(35, 80, 250, 146);
[vc.view addSubview:aCustomMsgBoxView];
}
But I don't need it in the above method, I need it in the method below where it doesn't work: 但是我在上面的方法中不需要它,在下面不起作用的方法中我需要它:
-(IBAction)hideMsgBox:(id)sender
{
[newAnnotationTitle resignFirstResponder];
[aCustomMsgBoxView removeFromSuperview];
}
Of course both methods sit in the same class... 当然,这两种方法都位于同一类中。
Why isn't the view being removed from the screen?? 为什么不从屏幕上删除视图?
Following code may be help for remove UIView (aCustomMsgBoxView) 以下代码可能有助于删除UIView(aCustomMsgBoxView)
-(IBAction)hideMsgBox:(id)sender
{
[newAnnotationTitle resignFirstResponder];
[UIView animateWithDuration:0.25
animations:^{ self.aCustomMsgBoxView.alpha = 0.0;}
completion:^(BOOL finished){ [ self.aCustomMsgBoxView removeFromSuperview]; }];
}
Thanks :) 谢谢 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.