我有一个视图用作另一个自定义警报视图的背景(浅灰色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];
我怎么能总是解雇的背景有何看法?
感谢
非常感谢,几个编辑虽然...在你的`animateWithDuration:0.5f`之后,你有'持续时间'一词不应该在那里。此外,完成块处理程序应该是`完成:^(BOOL完成){` – joec 2010-11-30 19:45:51