【发布时间】:2010-06-09 11:57:54
【问题描述】:
我以编程方式将 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];
单击按钮时我需要删除所有子视图。
我试过了:
[self.view removeFromSuperView]
但它不起作用。
【问题讨论】:
标签: objective-c subview