내비게이션 컨트롤에 포함 된 테이블 뷰 컨트롤러를 통해 액세스하는 뷰 컨트롤러가 있습니다. 내 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
참조 할 iOS의 버전을 지정해야합니다. iOS 8에는 오리엔테이션 개념이 없으며 크기 클래스 만 있습니다. 또한 "tableView에 넣을 때 작동이 멈춘다"는 의미를 분명히해야합니다. 위의 ViewController 클래스에 하위 뷰로 UITableView를 추가하고 있습니까? 완전히 다른 UIViewController 또는 UITableViewController를 푸시합니까? – TheCodingArt
xcode 5, iOS 7 내 UI ViewController 내 UITableViewController에서 추진하고 있습니다. UITableViewController를 제거하면 코드가 회전하지 않도록 작동합니다. –