I’m trying to remove a UIView added from a NSNotification. When I press the button “Done” the app should remove screen3 but it doesn’t work. Any suggestions?
Here you have the code:
- (void) mostrarCompra:(NSNotification *) notification
{
[self buyView:self];
}
- (void)buyView:(id)sender
{
screen3 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
screen3.backgroundColor= [UIColor grayColor];
UIToolbar* tabBar = [UIToolbar new];
tabBar.barStyle = UIBarStyleDefault;
[tabBar sizeToFit];
[tabBar setFrame:CGRectMake(0,0,self.view.bounds.size.width,60)];
UIBarButtonItem *atras = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(returnBuy:)];
[tabBar setItems:[NSArray arrayWithObjects:atras,nil]];
[screen3 addSubview:tabBar];
[superwindow addSubview:screen3];
}
- (IBAction)returnBuy:(id)sender{
[screen3 removeFromSuperview];
}
Thanks.
use nslog just before adding screen3 as sub view and removing from superview as
NSLog(@”%@”,screen3);
if the out put is a reference to the same location at both places, then there is something other prblm, but it the value of pointer is differnt, like 0x324fa and 0xa214c then you are allocating or changing the value of screen3 during add and remove view. tell me if you get this in either case.