【发布时间】:2010-11-30 16:48:34
【问题描述】:
我有一个视图作为另一个自定义警报视图的背景(浅灰色 0.5 alpha)。
当用户点击自定义警报上的“确定”按钮时,我还想隐藏自定义警报和背景视图。
两个视图都是同一个父视图的子视图...
我在 buttonTapped: 方法中执行此操作以隐藏视图,并且它在第一次尝试时有效,但从第二次开始,后台视图永远不会关闭...警报每次都正确隐藏。
[UIView animateWithDuration:0.5f animations:^{
self.view.alpha=0.0f; //hide alert
[self.view.superview viewWithTag:1].alpha=0.0f; //hide background
}];
它们被添加为子视图,如下所示:
ResultDialogController *dialogController = [[[ResultDialogController alloc] initWithNibName:@"ResultDialogController_" bundle:nil] retain];
ResultBackgroundViewController *bgViewController = [[[ResultBackgroundViewController alloc] initWithNibName:@"ResultView" bundle:nil] retain];
dialogController.view.alpha=0;
bgViewController.view.alpha=0;
bgViewController.view.tag=1;
[UIView animateWithDuration:0.5f animations:^{
bgViewController.view.alpha=0.5f;
dialogController.view.alpha=1.0f;
}];
[self.view addSubview:bgViewController.view];
[self.view addSubview:dialogController.view];
[dialogController release];
[bgViewController release];
我怎样才能总是关闭背景视图?
谢谢
【问题讨论】:
标签: iphone objective-c uiview uiviewcontroller subview