簡體   English   中英

rootViewController的self.view和self.view .superview有什么區別?

[英]What is a difference between self.view and self.view .superview of a rootViewController?

我有一個分配為rootViewController的視圖控制器,如下所示:

self.viewCntrl = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewCntrl;

在同一個視圖控制器中,我有一個按鈕,並且我在按鈕單擊時執行過渡動畫,如下所示:

[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view.superview cache:YES];

但是當我這樣寫時它不起作用:

[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];

因為self是ViewController的對象,所以ViewController就是分配給self.window.rootViewController的對象 那么為什么要使用self.view.superview而不是self.view進行動畫處理?

根據您嘗試執行的動畫類型,答案可能在這里

如果要在過渡期間更改視圖的外觀(例如,從一個視圖切換到另一個視圖),請使用容器視圖(UIView的實例),如下所示:

  1. 開始動畫塊。

  2. 在容器視圖上設置過渡。

  3. 從容器視圖中刪除子視圖。

  4. 將新的子視圖添加到容器視圖。

  5. 提交動畫塊。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM