2010-07-12 64 views
1

在UIApplication中是否有像beginIgnoringInteractionEvents這樣的函數會忽略旋轉而不是觸摸?我需要我的應用程序不要在我出示的MPMovePlayerViewController中旋轉。系統忽略iPhone旋轉

感謝

[更新]

這裏是我的代碼 -

MPMoviePlayerViewController *mpViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:videoURL]]; 
[mpViewController shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight]; 
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]; 
[self presentMoviePlayerViewControllerAnimated:mpViewController]; 
[mpViewController release]; 

我把它加入兩個shouldAutorotateToInterfaceOrientation工作:和setStatusBarOrientation:方法。它在模擬器中工作。但是,如果我在播放視頻的同時旋轉iPhone,狀態欄也會旋轉,並保持豎屏方向。在http://i28.tinypic.com/357mrub.png

[UPDATE 2]

通過繼承MPMoviePlayerViewController(和實施shouldAutorotate方法)我的問題的

圖像,程序轉動,它應。只有視頻不播放,因爲該行

[self presentMoviePlayerViewControllerAnimated:mpViewController]; 

不接受我的子類。

「警告:不相容的Objective-C類型 '結構NoRotate *',預期 '結構MPMoviePlayerViewController *' 時傳遞參數1 'presentMoviePlayerViewControllerAnimated:' 從不同目標C型」

回答

6

在視圖中,目前,實現shouldAutoRotate方法,並簡單地返回「NO」。這將導致手機忽略任何和所有方向更改。

+0

它終於成功了!謝謝 – jmont 2010-07-16 05:34:25

0

也許你可以子類MPMoviePlayerViewController這樣

// NotRotatingMoviePlayerViewController.h 
@interface NotRotatingMoviePlayerViewController : MPMoviePlayerViewController { 
} 

@end 

// NotRotatingMoviePlayerViewController.m 
@implementation 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { 
    return (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft); 
} 

@end 
+0

謝謝,它只適用於視頻不會播放。 [self presentMoviePlayerViewControllerAnimated:mpViewController]; 這是它給我的警告 「警告:當從不同的Objective-C類型傳遞」presentMoviePlayerViewControllerAnimated:「的參數1時,預期的'struct MPMoviePlayerViewController *'不兼容的Objective-C類型結構NoRotate *' – jmont 2010-07-12 16:20:19