Delete view and load another view

I want to delete the view after clicking the button and load another kind of code that I am trying to explain to you, which is below

[self removeFromSuperview];
FZforgetpassword *forget=[[[NSBundle mainBundle]loadNibNamed:@"FZforgetpassword" owner:self options:nil] objectAtIndex:0];
forget.delegate=self;
forget.frame=self.bounds;
[forget showCustomView:4];
[self addSubview:forget];

first line I delete the view and then load another view, but I don't get the second view when I run this code

+4
source share
2 answers

Try it out.

//add subview first
FZforgetpassword *forget=[[[NSBundle mainBundle]loadNibNamed:@"FZforgetpassword" owner:self options:nil] objectAtIndex:0];
forget.delegate=self;
forget.frame=self.bounds;
[forget showCustomView:4];
[self addSubview:forget];
//finally remove 'self view'
[self removeFromSuperview];

Note: if you first delete the "I", then "[self addSubview: forget];" cannot be performed. because now "self = nil"

0
source

This is the removal of self from the supervisor, it will be released if you do not have a link to it:

[self removeFromSuperview];
0
source

All Articles