2011-05-16 31 views
0

我有一個在應用程序委託中製作的選項卡欄。通過調用一個按鈕點擊從標籤欄加載的視圖中的一個按鈕,我打開幫助屏幕,但是在加載後出現一個急動作。爲什麼在使用此UIView動畫塊時會看到生澀的動畫?

原諒我講informally..I已經挑選我的大腦試圖找出了這一點,在過去的幾個小時..

-(void)flipToHelp { 
HelpViewController *helpVariable = [[HelpViewController alloc] initWithNibName:@"HelpView" bundle:nil]; 
[self setHelpViewController:helpVariable]; 
[UIView beginAnimations:@"flipview" context:nil]; 
[UIView setAnimationDuration:0.5]; 
[UIView setAnimationCurve:UIViewAnimationCurveLinear]; 
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft 
forView:_window cache:YES]; 

[_window removeFromSuperview]; 
[helpVariable release]; 
self.window.rootViewController = self.HelpViewController; 
[UIView commitAnimations]; 
} 
+0

你爲什麼要調用'[_window removeFromSuperview]'?你不應該從窗口中刪除標籤欄控制器嗎? – 2011-05-16 20:30:49

+0

我試過,但我不斷收到一個錯誤,使用「self.window = self.HelpViewController;」 ...警告:語義問題:從'HelpViewController *'分配給'UIWindow *'的指針類型不兼容 – BlockReader 2011-05-17 00:52:03

+0

我不確定重新分配rootViewController是否更改視圖。如果是這樣,所有你需要做的就是刪除'[_window removeFromSuperview]'行。如果改變rootViewController是不夠的,你可以這樣做:'[self.tabBarController removeFromSuperview]; [self.window addSubview:self.HelpViewController.view];'。 – 2011-05-17 01:29:37

回答

0

只是爲了從評論線程重申,你不應該從它的超級視圖中刪除窗口(它在技術上不具有超級視圖,所以它可能導致問題)。 並設置窗口的rootViewController屬性應該換出視圖層次結構顯然,這個急動來自更改窗口的rootViewController屬性,所以也許解決方案是避免使用該屬性。以下是我認爲應該足以實現的目標:

-(void)flipToHelp { 
    HelpViewController *helpVariable = [[HelpViewController alloc] initWithNibName:@"HelpView" bundle:nil]; 
    [UIView beginAnimations:@"flipview" context:nil]; 
    [UIView setAnimationDuration:0.5]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:_window cache:YES]; 
    [self.tabBarController removeFromSuperview]; 
    [_window addSubview:helpVariable]; 
    [UIView commitAnimations]; 
} 
+0

我想這太代碼,仍然有躍動... – BlockReader 2011-05-17 14:30:00

+0

沒有抽搐這裏' - (無效){flipToHelp HelpViewController * helpVariable = [[HelpViewController頁頭] initWithNibName:@ 「HelpView」 捆綁:無]。 [self setHelpViewController:helpVariable]; [UIView beginAnimations:@「flipview」context:nil]; [UIView setAnimationDuration:0.5]; [UIView setAnimationCurve:UIViewAnimationCurveLinear]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:_window cache:YES]; [helpVariable release]; [self.window addSubview:self.HelpViewController.view]; [UIView commitAnimations]; }' – BlockReader 2011-05-17 14:31:17

+0

也許在設置'rootViewController'時,UIWindow如何更新視圖可能是一個問題。也許你最好的選擇是不要使用這個屬性 - 我會用你的解決方案更新答案。 – 2011-05-17 16:20:10

0
-(void)flipToHelp { 
    HelpViewController *helpVariable = [[HelpViewController alloc] initWithNibName:@"HelpView" bundle:nil]; 
    [self setHelpViewController:helpVariable]; 
    [helpVariable release]; 

    [UIView beginAnimations:@"flipview" context:nil]; 
    [UIView setAnimationDuration:0.5]; 
    [UIView setAnimationCurve:UIViewAnimationCurveLinear]; 
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft 
         forView:self.window 
          cache:YES]; 

    self.window.rootViewController = self.HelpViewController; 
    [UIView commitAnimations]; 
} 

這個怎麼樣的代碼?它仍然有一個生澀的動畫?

+0

@deekpak它仍然生澀 – BlockReader 2011-05-17 00:46:17