我有一個視圖用作另一個自定義警報視圖的背景(淺灰色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