问题描述
我在主视图中添加了这样的子视图:
I've added a sub view like this in the main view:
BTLPXYPad *XYPad = [[BTLPXYPad alloc] initWithFrame: CGRectMake (30, 10, 280, 460)];
[window addSubview:XYPad];
完成我需要的所有工作,然后在 BTLPXYPad 类中使用它删除它:
done all my bits that i need to and then removed it using this in the BTLPXYPad class:
[self removeFromSuperview];
我需要的是在任务结束后执行任务.我知道使用 UIViewController 类型类我可以使用 viewDidDissapear 但我似乎无法为 UIView 类型找到相同的东西.请问有人可以帮忙吗?
What I need is to perform a task once it has gone. I know that with a UIViewController type class I could use viewDidDissapear but I can't seem to find the same thing for a UIView Type. Can anyone help please?
推荐答案
要知道您的视图何时被实际删除,您可以实现 didMoveToSuperview
并检查 superview 现在是否为 nil代码>
To know when you a view has actually been removed you could implement didMoveToSuperview
and check if the superview is now nil
- (void)didMoveToSuperview;
{
[super didMoveToSuperview];
if (!self.superview) {
NSLog(@"Removed from superview");
}
}
这篇关于UIView 的 viewDidDisappear的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!