Tag: uiinterfaceorientation

UIWebView横向旋转不填充视图

我有我的UIWebView的问题。 当视图加载它在任何方向加载罚款,完美填充整个页面等 但是,如果我加载它的肖像,然后旋转设备的Web视图不会填满整个右侧,我不能为我的生活弄清楚为什么。 这是我的观点做加载方法 – (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait){ self.measurementsWebView.frame = CGRectMake(0, 0, 320, 367); }else if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight){ self.measurementsWebView.frame = CGRectMake(0, 0, 480, 218); } NSString *path […]

强制方向改变有时不起作用

当我的应用程序中按下某个button时,视图应该将方向从纵向改为横向。 当用户回来时,视图控制器应该改回肖像。 但有时方向不会改变或使用错误的视图框架。 这是我的代码 -(void)btnSignClicked:(CustomSignButton *)btn { isSignButtonClicked = true; if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_0) { NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]; [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; } else { [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:YES]; } selectedWaiverId = btn.customTag; SignatureView *obj = [[SignatureView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) delegate:self]; // Most of time got size (568,320) but some time […]

如何旋转控制器中不允许旋转其接口的视图?

帮我解决任务 – 我有一个viewController不允许旋转其接口: – (BOOL)shouldAutorotate { return NO; } – (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } 但是我需要旋转出现在这个控制器中的alertView! 所以如果用户旋转设备,alertView应该跟随旋转,主界面仍然静止。 我试图订阅通知: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceRotated:) name:UIDeviceOrientationDidChangeNotification object:nil]; 但在我的deviceRotated:我收到这样的有效载荷的通知: NSConcreteNotification 0x101dc50 {name = UIDeviceOrientationDidChangeNotification; object = <UIDevice: 0x103e640>; userInfo = { UIDeviceOrientationRotateAnimatedUserInfoKey = 1; }} NSConcreteNotification 0x101dc50 {name = UIDeviceOrientationDidChangeNotification; object = <UIDevice: 0x103e640>; userInfo = { UIDeviceOrientationRotateAnimatedUserInfoKey = […]

模式视图控制器强制在iOS 6中的横向方向

我有一个以纵向模式呈现的UITabBarController。 在其中一个选项卡上,我有一个button,显示一个UIViewController模态(一个简单的故事板segue执行操作)。 我想要在横向模式下显示此模式视图,但是我无法自动旋转。 我有这在模态视图控制器 – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft); } 我已经添加landscapeLeft到.plist支持的方向(虽然这也允许TabBar旋转,我不想) 我也将其添加到模态视图的ViewDidLoad [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft; 但我不能让它自己旋转。 谢谢 编辑—- 看来应该AutoRotate甚至不被称为! 此外,我试图检测方向和下面的代码总是显示2,无论方向! if ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortrait) { NSLog(@"1"); self.hostView.frame = CGRectMake(0, 60, 200, 255); } else { NSLog(@"2"); self.hostView.frame = CGRectMake(0, 45, 480, 255); } 编辑2 — 我的错。 我想我应该提到我正在使用iOS 6.显示器在iOS 5上自动旋转。shouldAutorotateToInterfaceOrientation已弃用,所以我需要阅读新的方法。

iOS设备快速旋转180°会导致相机颠倒

我已经实现了下面的代码来改变基于AVCaptureVideoSession的方向: – (AVCaptureVideoOrientation)interfaceOrientationToVideoOrientation:(UIInterfaceOrientation)orientation { switch (orientation) { case UIInterfaceOrientationPortrait: return AVCaptureVideoOrientationPortrait; case UIInterfaceOrientationPortraitUpsideDown: return AVCaptureVideoOrientationPortraitUpsideDown; case UIInterfaceOrientationLandscapeLeft: return AVCaptureVideoOrientationLandscapeLeft; case UIInterfaceOrientationLandscapeRight: return AVCaptureVideoOrientationLandscapeRight; default: break; } NSLog(@"Warning – Didn't recognise interface orientation (%ld)",(long)orientation); return AVCaptureVideoOrientationPortrait; } 这个代码几乎完美的工作。 但是,发生的一个问题是,如果您快速旋转iOS设备180度,相机将显示颠倒。 以下是相机视图在旋转之前的样子: 轮换之后的样子如下所示: 另外,这里是我的viewDidLayoutSubviews实现: – (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; previewLayer.frame = self.view.bounds; self.view.translatesAutoresizingMaskIntoConstraints = NO; previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; […]

iOS 8 GM不会更新集合视图的约束

在Xcode 6 Beta 7及之前的所有版本中,我有一个集合视图,当iPad在横向和纵向之间旋转时,它将更新其单元格上的约束。 现在它根本没有更新,实际上它看起来和我在XIB中保持一致,这意味着它根本不会更新。 看来我正在使用的可重复使用的视图正确更新,但单元格当然不是。 有没有人遇到这个问题呢? 任何人有任何想法如何通过它? 我正在使用iOS 7.1模拟器。

确定屏幕的方向而不是设备的方向

[[UIDevice currentDevice] orientation]方法返回了纵向和横向之外的多个方向。 我很清楚检查返回的方向是否为“有效”,不幸的是如果返回的方向不是“有效”,当我的应用程序需要一个特定的方向来确定运行的方法,我无法知道哪种方法是适当。 我已经尝试了一些解决scheme,但现在唯一能够解决的问题是检查方向是LandscapeLeft还是LandscapeRight ,如果不是,我认为屏幕是纵向的。 不幸的是,当设备面朝上并且屏幕处于横向时,这不是真的。 我试图使用父视图控制器的方向: parentController.interfaceOrientation; 不幸的是,它返回UIDeviceOrientationUnknown 。 我search和谷歌search谁遇到了这个问题的其他人。 对我来说,苹果似乎很愚蠢,除了LandscapeLeft/Right和PortraitUp/Down ,其他的方向都没有。 我真正需要的是应用程序的方向而不是设备,因为这些有时是不一致的。 有什么build议?

为什么我的观点仍然呈现在风景中?

我的视图是由导航控制器控制的,所以我将支持的方向设置为导航控制器,以显式地纵向和纵向更新,这是有效的,但是如果先前的视图在视图被调用的情况下处于横向,它将呈现在横向并保持风景,直到设备旋转..如何防止这种情况? 这是我的代码: class EditProfileViewController: UIViewController, UINavigationControllerDelegate override func viewDidLoad() { super.viewDidLoad() navigationController?.delegate = self } func navigationControllerSupportedInterfaceOrientations(navigationController: UINavigationController) -> UIInterfaceOrientationMask { return [UIInterfaceOrientationMask.Portrait, UIInterfaceOrientationMask.PortraitUpsideDown] } 我以为上一行将视图永久locking为肖像,我该怎么做?

iOS 6旋转不起作用

我已经覆盖了我的UINavigationController来实现这些方法: -(BOOL)shouldAutorotate { return [[self.viewControllers lastObject] shouldAutorotate]; } -(NSUInteger)supportedInterfaceOrientations { return [[self.viewControllers lastObject] supportedInterfaceOrientations]; } – (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation]; } 现在从我的第一视图,我模态地呈现这个MSNavigationPaneViewController 在这里就像一个Facebook侧滑标签栏控制器。 我需要在这里显示的我的视图控制器中的一个显示横向,而应用程序的其余视图是仅肖像。 所以在我添加的所有其他视图控制器中: -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } – (BOOL)shouldAutorotate { return UIInterfaceOrientationMaskPortrait; } 并在我想要的景观,我已经添加: – (BOOL)shouldAutorotate { return UIInterfaceOrientationMaskLandscape; } -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; } 然而,我所有的观点旋转。 如果我在这些其他视图上更改了shouldRotate为NO,那么它们将停留在Portrait中,而我想成为Landscape的视图可以旋转,但是我不能让它自己旋转。 另外,一旦旋转,如果我回到另一个有shouldRotate = NO;视图shouldRotate […]

如何在iOS5中获取默认的LandscapeLeft方向?

对不起,如果这个问题是重复的,但我找不到相同的解决scheme。 在iOS6中,如果我想为一个UIViewController设置默认方向,我只需使用: – (BOOL)shouldAutorotate { return YES; } – (NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskLandscapeLeft; } 但是如何在iOS5中做同样的事情,我testing了两个: – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);//not default } and – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { return (toInterfaceOrientation == UIInterfaceOrientationMaskLandscapeLeft);// = return NO; } 但默认的方向总是肖像。任何build议?