Tag: 方向

window.orientation在iOS和Android中返回不同的值

我在iPad (Safari浏览器)和Samsung Tab 2 (默认浏览器)上testing我的Web应用程序。 window.orientationchange在两个设备中返回不同的值。 $(document).ready(function() { window.addEventListener("orientationchange", centerLoginBox); window.addEventListener("load", centerLoginBox); }); function centerLoginBox() { if (window.orientation == 90 || window.orientation == -90) { //Landscape Mode $('#loginbox').css('margin-top', '20%'); alert(window.orientation); } else if (window.orientation == 0 || window.orientation == 180) { //Portrait Mode $('#loginbox').css('margin-top', '40%'); alert(window.orientation); } 在标签2中,警报对于横向模式抛出“0”和“180”,对于纵向模式抛出值“90”和“-90”( 在iPad中只是相反的行为 )。 这是iOS和Android的一些devise差异吗? 什么可能是这个问题的通用解决scheme?

检测iOS设备方向locking

如何以编程方式检查设备方向是否在iOS中被locking? 我在UIDevice中看不到任何东西。 我知道这应该是透明的应用程序。 但是如果方向被locking,我想改变显示内容的方式(如Youtube应用程序所做的;locking为横向而不是纵向)。 这一定是可能的。

UINavigationController方向更改中的ViewController

所以我有以下层次结构: UINavigationController – > RootViewController( UIViewController ) – > UITableViewController – > DetailViewController( UIViewController ) 我想lockingRootViewController上的方向为只有肖像,但保留其余视图控制器的所有方向。 如果我把这个子类UINavigationController : – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } -(NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskPortrait; } 所有的视图控制器然后locking到肖像。 我的问题是,有没有办法只lockingRootViewController到肖像,但保留其他视图控制器的所有选项?

presentViewController不支持iOS 6中的方向

我正在使用这个代码 if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]) { [self presentViewController:navigationControllerCustom animated:YES completion:nil]; } else { [self presentModalViewController:navigationControllerCustom animated:YES]; } 我的应用程序有两个方向肖像和肖像颠倒。 此代码适用于iOS 5.1,但在iOS 6上方向不起作用 我还在我的navigationControllerCustom类中添加了这段代码 – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown); } -(NSUInteger)supportedInterfaceOrientations { return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown); } 请帮我解决这个问题。 提前致谢。

获取当前界面方向的不同方法?

有三种方法可以获取我所知道的当前界面方向: self.interfaceOrientation [[UIApplication sharedApplication] statusBarOrientation] [[UIDevice currentDevice] orientation] 他们之间有什么不同?

设备方向 – 以合法方式更改(iOS 4.0+)

我的应用程序有导航栏,第一个屏幕返回YES为方向,第二个设置为基于用户在第一个屏幕中select的某个方向。 从第二个画面回到第一个画面后,如果用户手持纵向设备而界面处于横向画面,则第一个画面设置为横向。 这是因为 (BOOL)shouldAutorotateToInterfaceOrientation(UIInterfaceOrientation)interfaceOrientation 仅在更改设备方向后才被调用。 我想检查什么是设备方向atm和设置界面的方向。 尝试: //1st method: UIViewController *rotateTheScreen = [[UIViewController alloc]init]; [self presentModalViewController:rotateTheScreen animated:NO]; [self dismissModalViewControllerAnimated:NO]; [rotateTheScreen release]; //2nd method: UIInterfaceOrientation interfaceOrientation = self.interfaceOrientation; //3rd method: UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation]; 第一个是奇怪的,除了从界面方向=横向和设备方向=横向(这里是一个错误,他旋转到横向)回来的所有情况下,第二个检查界面,如名称告诉,并没有工作我的问题第三据我所知是私人的,苹果拒绝使用这个应用程序。

在iOS中的方向中加载不同的xib文件

我创build了两个.xib文件,一个用于纵向模式,另一个用于横向模式, 每次旋转我想加载相应的.xib文件, 这是我的代码片段, ViewAppDelegate.m类 – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; if ([UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationPortrait | [UIApplication sharedApplication].statusBarOrientation==UIInterfaceOrientationPortraitUpsideDown) { self.viewController = [[OrientationViewController alloc] initWithNibName:@"PortraitController" bundle:nil]; UINavigationController *navigationController=[[UINavigationController alloc] initWithRootViewController:self.viewController]; self.window.rootViewController = navigationController; } else{ self.viewController = [[OrientationViewController alloc] initWithNibName:@"LandscapeController" bundle:nil]; UINavigationController *navigationController=[[UINavigationController alloc] initWithRootViewController:self.viewController]; self.window.rootViewController = navigationController; } [self.window makeKeyAndVisible]; […]

如何locking在iPhone纵向/横向屏幕?

我的应用程序支持所有的方向,但在less数情况下,我想locking屏幕 纵向/横向模式。 在我的应用程序中,我有两种pdf文档。 一个是纵向文件,另一个是横向文件。 我只想在纵向视图中打开纵向文档,而在纵向文档中打开 仅景观视图。 我想这样做:如果我的应用程序打开横向视图,我点击 纵向文档,所以它必须旋转纵向视图和相同的景观如此 我的应用程序打开纵向视图,当我点击景观文件 必须旋转或者只能在横向打开文档。 希望我让你们明确的赦免我的英语希望你明白我想要什么 需要你的帮助 。 先谢谢你 这里是我的一些代码: – (void)viewDidLoad { [super viewDidLoad]; UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) { NSLog(@"Portrait"); if ([orientationObject isEqualToString:@"p"]) { //If the document is portrait pdfScrollViewFrame = CGRectMake(-0.0, -80.0, 770.0, 1085.0); } else{ // If […]

supportedInterfaceOrientations不起作用

我想要一些我的ViewControllers风景和一些肖像,所以这就是我所做的: 我启用了横向模式: 接下来,我将这些代码行添加到视图控制器,我想成为肖像: -(NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationPortrait; } -(BOOL)shouldAutorotate { return NO; } – (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; } 但是当我旋转他们,他们仍然去风景模式。我可以解决这个问题?

iOS高级手势:获取滑动方向vector

通过文档查看,似乎新的高级手势API不能确定超出基本{左,右,上,下}的滑动方向。 我需要滑动的起点和方向。 有没有办法检索这个,而不是从头开始编写我自己的高级手势库了基本的手势? 如果这是我唯一的select,任何人都可以指向我的一些开源代码这样做?