我们在appdelegate 里面用代码把屏幕转向禁止
帮帮忙,不要沉。。啊
快来人哦,在线等呢。。。。。
//Appdelegate.h
@property(nonatomic,assign)BOOL Orientations;
//Appdelegate.m
}
//要旋转的页面中
UIDevice *device = [UIDevice currentDevice]; //Get the device object
[device beginGeneratingDeviceOrientationNotifications]; //Tell it to start monitoring the accelerometer for orientation
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; //Get the notification centre for the app
[nc addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:device];
AppDelegate *delegate=[[UIApplication sharedApplication]delegate];
delegate.Orientations=YES;
(void)orientationChanged:(NSNotification *)note {
UIDeviceOrientation o = [[UIDevice currentDevice] orientation];
switch (o) {
case UIDeviceOrientationPortrait: // Device oriented vertically, home button on the bottom
break;
case UIDeviceOrientationPortraitUpsideDown: // Device oriented vertically, home button on the top
break;
case UIDeviceOrientationLandscapeLeft: // Device oriented horizontally, home button on the right
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES];
break;
case UIDeviceOrientationLandscapeRight: // Device oriented horizontally, home button on the left
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:YES];
break;
default:
break;
}
}
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// 操作
return YES; // YES为允许横屏,否则不允许横屏
}
希望对你有帮助。
(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (self.allowRotation) {
return UIInterfaceOrientationMaskAll;
}
return UIInterfaceOrientationMaskPortrait;
}
在appDelegate 定义一个bool的属性来控制特定页面是否可以旋转
给你一个建议 参照优酷播放器那种,使用仿射变换将界面转90度,然后自适应屏幕就行了,这是手动的,最好的方法