我创建了一个解开编程和做动作如何通过一个按钮来消失的UIView点击
{
UIButton *myButton1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton1.frame = CGRectMake(20, 20, 80, 44);
[myButton1 setTitle:@"Click Me!" forState:UIControlStateNormal];
[myButton1 addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:myButton1];
}
和IBAction为我有一个UIView作为这样
- (IBAction)buttonClicked:(id)sender
{
CGRect myFrame = CGRectMake(0, 300, 100, 50);
UIView *myView = [[UIView alloc] initWithFrame:myFrame];
myView.backgroundColor = [UIColor lightGrayColor];
[self.view addSubview:myView];
[myView release];
}
我现在想子视图当用户第二次按myButton1时子视图必须消失。我怎样才能做到这一点?
thanx Dipak。工作正常 – jason 2012-01-19 08:07:03