2014-11-13 1 views
0

내비게이션 컨트롤에 포함 된 테이블 뷰 컨트롤러를 통해 액세스하는 뷰 컨트롤러가 있습니다. 내 View Controller를 항상 세로 방향으로하고 싶습니다. 뷰 컨트롤러에는 자동으로 회전하거나 항상 가로 방향으로 표시 할 수있는 비디오를 시작하는 버튼이 있습니다.테이블 뷰 컨트롤러에서 자동으로 회전하는보기를 방지합니다.

다음 코드는 tableview 컨트롤러없이 작동하지만 tableview 넣을 때 작동하지 않습니다.

미리 도움을 청하십시오.

#import "ViewController.h" 

@interface ViewController() 

@end 

@implementation ViewController 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib.[[UIDevice  currentDevice] beginGeneratingDeviceOrientationNotifications]; 



} 

- (void)didReceiveMemoryWarning 
{ 
[super didReceiveMemoryWarning]; 
// Dispose of any resources that can be recreated. 

} 

- (IBAction)play:(id)sender { 

    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] 
             pathForResource:@"FINAL_De_Air_Purge_System" ofType:@"mp4"]]; 
    MPMoviePlayerViewController *playercontroller = [[MPMoviePlayerViewController alloc] 
                initWithContentURL:url]; 
    [self presentMoviePlayerViewControllerAnimated:playercontroller]; 
    playercontroller.moviePlayer.movieSourceType = MPMovieSourceTypeFile; 
    [playercontroller.moviePlayer play]; 
    playercontroller = nil; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { 

return UIInterfaceOrientationPortrait; 

} 

- (BOOL)shouldAutorotate { 
return NO; 
} 
@end 
+0

참조 할 iOS의 버전을 지정해야합니다. iOS 8에는 오리엔테이션 개념이 없으며 크기 클래스 만 있습니다. 또한 "tableView에 넣을 때 작동이 멈춘다"는 의미를 분명히해야합니다. 위의 ViewController 클래스에 하위 뷰로 UITableView를 추가하고 있습니까? 완전히 다른 UIViewController 또는 UITableViewController를 푸시합니까? – TheCodingArt

+0

xcode 5, iOS 7 내 UI ViewController 내 UITableViewController에서 추진하고 있습니다. UITableViewController를 제거하면 코드가 회전하지 않도록 작동합니다. –

답변

0

난 당신이 다음을 따르는 경우에, 당신은 잘한다고 생각 :

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window 
{ 
    return UIInterfaceOrientationMaskAllButUpsideDown; 
} 

`- (NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscape; 
}` 

에 앱 위임에 있어야 원하지 않는 모든 ViewControllers에 있어야합니다 회전 할

- (BOOL)shouldAutorotate 
{ 
    return YES; 
} 

쇼 uld가 회전 할 수 있음을 iOS에 알리는 동영상 플레이어를 밀어 넣는 ViewController에 넣으십시오.

무비 플레이어를 밀면 회전이 가능하다는 것을 알아야합니다. 동영상 플레이어를 표시/숨길 때 이전 viewController를 원하는대로 세로로 회전해야합니다.