2012-01-02 119 views
0

我在使用c「willRotateToInterfaceOrientation」函數播放視頻時遇到問題。最初,我將我的主視圖設置爲橫向模式。視頻正在播放,但後來我試圖將其旋轉到肖像模式,我的項目不會調用「willRotateToInterfaceOrientation」,但當我試圖將其旋轉回landscapeleft模式,然後再次旋轉回肖像模式時,它只是時間「willRotateToInterfaceOrientation」被調用。誰能幫幫我嗎?謝謝willRotateToInterfaceOrientation沒有被調用

回答

4

試試這個,而不是在willRotateToInterfaceOrientation中實現代碼。

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; 
     NSNotificationCenter* notifCenter = [NSNotificationCenter defaultCenter]; 
     [notificationCenter addObserver:self 
       selector:@selector(orientationChanged) 
        name:UIDeviceOrientationDidChangeNotification 
       object:nil]; 

Add the following method 
-(void) orientationChanged 
{ 
     //Copy code from your willRotateToInterfaceOrientation method here. 
} 
+0

我想你的建議它的工作原理正是我想要的,但另一個問題出現我的主要觀點是,輪值子視圖這是我的看法movieplayercontroller不旋轉的唯一的事情。謝謝 – Jahn 2012-01-02 07:48:23

+0

@Jahn:要麼你必須設置movieplayer的transform屬性或實現[movieController.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; – vtechig 2012-01-02 09:39:35

+0

我試過你的建議,但仍然沒有旋轉我的movieplayer視圖的成功。但感謝您的建議。 – Jahn 2012-01-02 10:25:26

相關問題