Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

viewDidDisappear for UIView

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

done all my bits that i need to and then removed it using this in the BTLPXYPad class:

    [self removeFromSuperview];

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?

like image 836
user3694378 Avatar asked Oct 17 '25 19:10

user3694378


1 Answers

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");
  }
} 
like image 155
Paul.s Avatar answered Oct 20 '25 10:10

Paul.s



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!