相关疑难解决方法(0)

删除所有子视图?

当我的应用程序返回其根视图控制器时,在该viewDidAppear:方法中我需要删除所有子视图.

我怎样才能做到这一点?

subview ios

312
推荐指数
7
解决办法
17万
查看次数

如何删除Objective-C中的子视图?

我以编程方式将UIButton和UITextView作为子视图添加到我的视图中.

notesDescriptionView = [[UIView alloc]initWithFrame:CGRectMake(0,0,320,460)];
notesDescriptionView.backgroundColor = [UIColor redColor];
[self.view addSubview:notesDescriptionView];

textView = [[UITextView alloc] initWithFrame:CGRectMake(0,0,320,420)]; 
[self.view addSubview:textView]; 
printf("\n description  button \n");

button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button
  addTarget:self action:@selector(cancel:)
  forControlEvents:UIControlEventTouchDown];
[button setTitle:@"OK" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 420.0, 160.0, 40.0);
[self.view addSubview:button];
Run Code Online (Sandbox Code Playgroud)

我需要在单击按钮时删除所有子视图.

我试过了:

[self.view removeFromSuperView]
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

objective-c subview

26
推荐指数
3
解决办法
5万
查看次数

标签 统计

subview ×2

ios ×1

objective-c ×1