Ios 从纵向视频到横向视频
我知道像这样的问题可能已经存在了,但为了像我这样的人,我会继续问下去 我有一个应用程序,设置为只允许纵向,但此设置会影响我的视频,因为我希望只有视频能够在横向播放。是否有一种方法可以添加到.m文件中以使其正常工作?这是我的密码Ios 从纵向视频到横向视频,ios,xcode,ios5,video,ios6,Ios,Xcode,Ios5,Video,Ios6,我知道像这样的问题可能已经存在了,但为了像我这样的人,我会继续问下去 我有一个应用程序,设置为只允许纵向,但此设置会影响我的视频,因为我希望只有视频能够在横向播放。是否有一种方法可以添加到.m文件中以使其正常工作?这是我的密码 #import "BIDVideosViewController.h" @interface BIDVideosViewController () @end @implementation BIDVideosViewController @synthe
#import "BIDVideosViewController.h"
@interface BIDVideosViewController ()
@end
@implementation BIDVideosViewController
@synthesize moviePlayer ;
@synthesize tableList;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UITableView *table = [[UITableView alloc]initWithFrame:self.view.bounds];
[table setDelegate:self];
[table setDataSource:self];
[self.view addSubview:table];
tableList = [[NSMutableArray alloc] initWithObjects:@"Gangan",@"SwimGood",@"German Ice", nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [tableList count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *DisclosureButtonIdentifier = @"DisclosurebutotonIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:DisclosureButtonIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DisclosureButtonIdentifier];
}
NSInteger row = [indexPath row];
NSString *rowString = [tableList objectAtIndex:row];
cell.textLabel.text = rowString;
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
{
NSBundle *str = [tableList objectAtIndex:indexPath.row];
if ([str isEqual:@"Gangan"])
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *thePath = [bundle pathForResource:@"Gangan" ofType:@"mp4"];
NSURL *theurl = [NSURL fileURLWithPath:thePath];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theurl];
[moviePlayer setMovieSourceType:MPMovieSourceTypeFile];
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES];
[moviePlayer play];
}
else if ([str isEqual:@"SwimGood"])
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *thePath = [bundle pathForResource:@"SwimGood" ofType:@"mp4"];
NSURL *theurl = [NSURL fileURLWithPath:thePath];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theurl];
[moviePlayer setMovieSourceType:MPMovieSourceTypeFile];
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES];
[moviePlayer play];
}
else if ([str isEqual:@"German Ice"])
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *thePath = [bundle pathForResource:@"German Ice" ofType:@"mp4"];
NSURL *theurl = [NSURL fileURLWithPath:thePath];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theurl];
[moviePlayer setMovieSourceType:MPMovieSourceTypeFile];
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES];
[moviePlayer play];
}
}
}
@end
在视图控制器.m文件中,您应该
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
对于支持的方向,您可以返回YES
,这将使您能够旋转视频
另外,如果使用UINavigationController,此方法也不会起作用,除非UINavigationController
implement-(BOOL)管理的所有视图都应该以相同的方式进行AutoRotateTointerFaceOrientation:(UIInterfaceOrientation)interfaceOrientation
此外,在目标->项目->摘要中,您可以设置支持的方向
编辑:
去寻找UIInterfaceOrientation。这里有你需要的常数
我会这样写:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if (interfaceOrientation == UIInterfaceOrientationPortrait)
return YES;
if (interfaceOrientation == UIInterfaceOrientationLandscapeRight)
return YES;
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
return YES;
}
谢谢..假设我想用“lanscapeleft”和“landscaperight”怎么写,你能修改答案吗:)谢谢@Martinberger可能的重复