我更加清新IOS。在我的iPad应用程序中,我有6个视图。默认情况下,我将所有屏幕的方向固定为横向模式。但是当我打开特定的视图时,我的第5个视图必须改变为肖像模式,是否有任何编程代码可以更改该特定的视图方向?你能帮我解决这个问题吗?提前致谢。如何更改单个视图的方向而不是所有视图的ipad?
-1
A
回答
0
1.You需要通过调用
-(void)beginGeneratingDeviceOrientationNotifications
方法生成DeviceOrientation通知。
2.in的UIViewController它控制你的视图中添加通知观察
[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rotateMyUIView:) name:UIDeviceOrientationDidChangeNotification object:nil];
3.in rotateMyUIView
梅托德旋转使用
myView.transform = CGAffineTransformMakeRotation(M_PI/2); // you must check orientation first
0
你的UIView您可以在特定视图 - 控制器实现didRotateFromInterfaceOrientation
你不想受到影响。
0
了iOS 6后,你可以做这样的..
在AppDelegate.h文件
@interface AppDelegate : UIResponder <UIApplicationDelegate>
{
BOOL allowRotation;
}
在AppDelegate.m文件
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
allowRotation = NO;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeDeviceOrientation:) name:@"ChangeDeviceOrientation" object:nil];
return YES;
}
- (void) changeDeviceOrientation:(NSNotification*)notification {
if(allowRotation)
{
allowRotation = NO;
}else
{
allowRotation = YES;
}
}
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
NSLog(@"Not FullScreen");
if (allowRotation) {
NSLog(@"FullScreen");
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
return UIInterfaceOrientationMaskPortrait;
}
并在您的视图 - 控制(这viewC你想改变方向)叫这个通知
-(void)viewWillDisappear:(BOOL)animated{
[[NSNotificationCenter defaultCenter] postNotificationName:@"ChangeDeviceOrientation" object:nil];
}
-(void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"ChangeDeviceOrientation" object:nil];
}
+0
根据您的代码,从应用程序开始,所有屏幕仅显示肖像模式。但我的要求是,除特定屏幕外,所有5个屏幕都应处于横向模式。当应用程序启动时,第一个屏幕应该处于横向模式,如果我进入第5个屏幕,它必须自动更改为纵向模式,这就是问题所在。 – Ramesh
相关问题
- 1. 以编程方式更改视图方向而不旋转ipad
- 2. iPad - 方向更改和视图?
- 3. iPad:改变加载方向的视图
- 4. 以不同的方向更改视图
- 5. 强制一个视图的ipad方向
- 6. 如何在iPhone中更改方向时更改视图控制器的视图?
- 7. 在swift中更改子视图的alpha而不是父视图
- 8. 更改iPad的方向,旋转状态栏,工具栏,但不是主视图
- 9. 如何更改方向更改时的视图布局?
- 10. 缩放iPhone的方向更改视图
- 11. 更改iPhone中视图的方向
- 12. 如何更改所选UITableViewCell的视图
- 13. 如何在一个视图之后而不是所有视图之间同时动画一个视图?
- 14. 如何在不同的方向更改视图
- 15. 如何更改特定视图的视图控制器的方向
- 16. 如何将特定视图的方向更改为横向?
- 17. iPad Modal View取消更改父视图方向
- 18. 如何在iPhone中打开所有照片视图而不是相册视图?
- 19. 更改子视图的alpha值而不更改父视图的alpha值
- 20. 是否可以在设备方向更改的控制器上更改单个视图的方向?
- 21. 如何删除子视图(或视图的所有子视图)
- 22. 如何根据滚动视图方向更改图像(Android)
- 23. 如何更改视图的特定部分的方向iPhone
- 24. 了解坐标,视图,子视图和方向更改
- 25. iOS - 用设备方向更改视图
- 26. 以方向更改视图布局
- 27. Android - 添加视图方向更改
- 28. iPhone与iPad的多个视图单个视图都共享视图控制器
- 29. 如何更改所有可用视图单元格中的图像
- 30. 更改方向更改视图背景图像
您正在使用哪个iOS版本? – Dilip