我試圖刪除從NSNotification
添加的UIView
。當我按下「完成」按鈕時,應用程序應該刪除screen3
,但它不起作用。有什麼建議麼? 在這裏你的代碼:從註冊了UIButton元素的IBAction中刪除UIView
- (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];
}
謝謝。
你確定方法returnBuy:被調用嗎? – yehnan
在** returnBuy * –