我似乎无法实现删除视图子视图的子视图。就像这样:
[self.view addSubview:myView];
[myView addSubview:overlay];
我的 .h :
@interface
UIView *myView;
IBOutlet Overlay *overlay;
...
}
@property (strong, nonatomic) UIView *myView;
@property (strong, nonatomic) IBOutlet Overlay *overlay;
...
.m:
-(void) method {
UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(420.0f,0.0f,604.0f,768.0f)];
[self.view addSubview:myView];
Overlay *o = [[Overlay alloc] initWithFrame:CGRectMake(000.0f,000.0f,604.0f,768.0f)];
[myView addSubview:o];
}
我试过了[myView removeFromSuperview]
,[myView removeFromSuperview]
在里面void method
,它有效。我需要的是让它在外部或不同的地方工作,void
但我所做的却不起作用。
笔记:
它说当我分配 myView"Local declaration of 'myView' hides instance variable."