iOS7新特性 ViewController轉場切換(一) 以前總結和關鍵API介紹,ios7viewcontroller

來源:互聯網
上載者:User

iOS7新特性 ViewController轉場切換(一) 以前總結和關鍵API介紹,ios7viewcontroller
@在iOS7之前,View Controller的切換主要有4種:
1. Push/Pop,NavigationViewController
2. Present and dismis Modal
3. UITabBarController
4. addChildViewController(一般用於自訂的繼承於 UIViewController 的容器子類)
iOS5,調用- (void)transitionFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion NS_AVAILABLE_IOS(5_0);

         (1)前面3種方法這裡就不多說了,很常見的系統方法.至於第四種,我在前面文章-剖析網易標籤欄的效果中已經做了闡述,但是它提供的容器轉場動畫只可以實現一些簡單的UIView動畫,但是難以重用,耦合高.

         (2)關鍵的API:

A.動畫控制器 (Animation Controllers) 遵從 UIViewControllerAnimatedTransitioning 協議,並且負責實際執行動畫。
B.互動控制器 (Interaction Controllers) 通過遵從 UIViewControllerInteractiveTransitioning 協議來控制可互動轉場。
C.轉場代理 (Transitioning Delegates) 根據不同的轉場類型方便的提供需要的動畫控制器和互動控制器。

   其中UINavigationControllerDelegate delegate 中新增了2個方法給NavigationController

               UIViewControllerTransitioningDelegate 新增transitioningDelegate  給Modal的Present和Dismis

          UITabBarControllerDelegate  delegate

- (id <UIViewControllerInteractiveTransitioning>)tabBarController:(UITabBarController *)tabBarController

                      interactionControllerForAnimationController: (id <UIViewControllerAnimatedTransitioning>)animationController NS_AVAILABLE_IOS(7_0);
- (id <UIViewControllerAnimatedTransitioning>)tabBarController:(UITabBarController *)tabBarController
            animationControllerForTransitionFromViewController:(UIViewController *)fromVC
                                              toViewController:(UIViewController *)toVC  NS_AVAILABLE_IOS(7_0);            

D.轉場上下文 (Transitioning Contexts) 定義了轉場時需要的中繼資料,比如在轉場過程中所參與的視圖控制器和視圖的相關屬性。 轉場內容物件遵從 UIViewControllerContextTransitioning 協議,並且這是由系統負責產生和提供的。
E.轉場協調器(Transition Coordinators) 可以在運行轉場動畫時,並行的運行其他動畫。 轉場協調器遵從 UIViewControllerTransitionCoordinator 協議。

          (3)新的API主要提供了2種VC切換的方式:
A.非互動式切換,即定義一種從一個VC到另一個VC的動畫效果,切換的時候自動播放,

B.互動式切換,這種方式同樣需要定義動畫效果,只是這個動畫效果會根據跟隨互動式手勢來切換VC並同時播放動畫效果。iOS7提供了一個預設的基於百分比的動畫實現 UIPercentDrivenInteractiveTransition,而且根據WWDC的說明,最簡單的實現互動式動畫的方法就是通過繼承 UIPercentDrivenInteractiveTransition。


            @待續.....下面一章通過實際Demo來展示


ios開發,一個view在幾個viewcontroller切換時位置依然保持在最上面,一直可見

你的view肯定不能塞到你切換的這個navigationcontroller。加到UIWindow裡,或是改變你的視圖結構,實現的辦法有很多。
不知道你說的是否是tabbar
 
ios oc xcode MPMoviePlayerController切換ViewController不播放

調用視圖切換類,視圖切換類會release掉AViewController,對吧?
首先確定你的AViewController的dealloc方法裡面寫[MPMoviePlayerController release]了。
然後在釋放之前,先把現正播放的視頻停止。
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.