简体   繁体   English

如何以横向模式以肖像方式显示?

[英]How to display in landscape mode in portrait?

I have a calculator screen in Iphone, when i launched it displayed in portrait,but i want to display the calculator screen in landscape mode from portrait and also change the orientation, how? 我在Iphone中有一个计算器屏幕,当我以纵向显示它时,我想以横向模式显示计算器屏幕,也可以改变方向,如何?

I tried the source code: 我试过源代码:

      self.view.transform = CGAffineTransformIdentity;
      self.view.transform = CGAffineTransformMakeRotation((M_PI * (90) / 180.0)); 
      self.view.bounds = CGRectMake(0.0, 0.0, 480, 320);

It is used first time launched only landscape mode in portrait, but change the orientation not working, any one help me. 它是第一次使用纵向仅启动横向模式,但改变方向不起作用,任何一个帮助我。

Try this: 尝试这个:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
[[self view] setBounds:CGRectMake(0, 0, 480, 320)];
[[self view] setCenter:CGPointMake(160, 240)];
[[self view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)]; 
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        return YES
    }

Now make use of any one method for ur rotation 
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;
    Hope this help.

THE same question here 同样的问题在这里

My sandbox app: https://github.com/comonitos/programatical_device_orientation 我的沙箱应用程序: https//github.com/comonitos/programatical_device_orientation

The solution is easy: 解决方案很简单:

in interface (h file) : 在接口(h文件)中:

    BOOL rotated;

in implementation (m file): 1. rewrite 在实现中(m文件):1。重写

    -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
    return rotated;
    }

2 call [self setup] 2通话[自我设置]

    -(void) setup { 
    rotated = YES; 
    [[UIDevice currentDevice] setOrientation:UIDeviceOrientationLandscapeLeft]; 
    rotated = NO; 
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 pushViewController:-当设备处于横向模式时,如何在仅纵向模式下显示? - pushViewController: - how to display in portrait only mode, when device is in landscape mode? 如何在appdelegate上查看横向和纵向模式? - How to check landscape and portrait mode on appdelegate? 如何从纵向自动旋转为横向模式? - How to autorotate from portrait to landscape mode? 如何将视图从纵向模式旋转到横向模式 - How to rotate view from portrait to landscape mode 如何知道横向或纵向模式下的照片? - How to know if photo in Landscape or Portrait mode? 方向肖像和风景模式 - Orientation portrait and landscape mode 为什么我的视图没有以横向显示而不是纵向显示? - Why doesn't my view display in Landscape instead of Portrait mode? 如果UIViewController的父级处于纵向模式,如何以横向模式加载UIViewController? - How to load a UIViewController in landscape mode if its parent is in Portrait mode? 如何在横向模式而不是纵向模式下捕获avfoundation - how to capture avfoundation in landscape mode instead of portrait mode 如何“旋转图像,仅当它处于纵向模式时(但不是在landScape模式下)” - How it is possible to 'rotate image, only if it is in portrait mode (But not in landScape mode)'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM