标签: uiinterfaceorientation

如何在iOS上旋转自定义初始屏幕?

我的启动画面工作正常,但我的应用程序在横向模式下工作,并且启动画面以默认纵向模式显示.

如何启动应用程序以使启动屏幕在我的应用程序之间的横向模式之间旋转?

我正在使用以下代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
    interfaceOrientation == UIInterfaceOrientationLandscapeRight)
    return YES;
else {
    return NO;  }
}
Run Code Online (Sandbox Code Playgroud)

而对于闪屏

-(void)displayScreen { 
UIViewController *displayViewController=[[UIViewController alloc] init];
displayViewController.view = displaySplashScreen;
[self presentModalViewController:displayViewController animated:NO];
[self performSelector:@selector(removeScreen) withObject:nil afterDelay:3.0];
} 
 -(void)removeScreen
{   [[self modalViewController] dismissModalViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)

但是如何将旋转放在显示屏内?

iphone ipad uiinterfaceorientation autorotate ios

5
推荐指数
1
解决办法
6969
查看次数

如何通过UIView参考获取设备方向?

我需要从ViewController获取设备方向.我不能依据:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
Run Code Online (Sandbox Code Playgroud)

因为它有时会返回未知方向(例如,当设备放在桌子上时).

我只需知道我当前的UIView显示的方向(左侧是横向还是横向右侧).当方向改变时,我不需要更新此值,我只想知道它,当我要求它时.只是一些参考view.orientation ;).有什么东西可以帮助我吗?我已经阅读了UIView文档,发现了一些对UIWindow的引用,但没有什么可以帮助我.

uiview uiinterfaceorientation ios

5
推荐指数
2
解决办法
7121
查看次数

shouldAutorotateToInterfaceOrientation在启动时调用两次

我正在开发iOS 5目标项目.我有如下定位方法.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{    
  NSLog(@" My Orientation");

  return YES;
}
Run Code Online (Sandbox Code Playgroud)

但是,当我的应用程序启动时,我的日志消息将在控制台上显示两次,即我Orientation将显示两次.我正在模拟器中测试我的应用程序,这只是在发布时发生,甚至没有更改orientation,然后再次更改方向.即

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
Run Code Online (Sandbox Code Playgroud)

每次被调用两次,我认为这不是一个正确的行为.任何帮助都是

赞赏.

cocoa-touch objective-c screen-orientation uiinterfaceorientation ios

5
推荐指数
1
解决办法
831
查看次数

通用应用程序中的IOS 6方向问题

在我的通用应用程序中,我需要处理iphone和ipad的不同方向.对于ipad,我需要允许横向和iphone肖像.我首先回复了以下代码

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
        return UIInterfaceOrientationIsPortrait(interfaceOrientation);

    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
Run Code Online (Sandbox Code Playgroud)

在IOS 5中工作正常但在IOS 6中,自动旋转方法根本没有被解雇.之后我改变了方法,

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

即使这种方法在IOS 6中也没有被解雇.

我的plist设置是

在此输入图像描述

我需要同时处理IOS 5和IOS 6的方向[iPhone-portrait,iPad-landscape].请指导我解决这个问题.

iphone ipad uiinterfaceorientation ios5 ios6

5
推荐指数
1
解决办法
1588
查看次数

iOS 7.仅为一个视图控制器更改页面方向

我有iPhone应用程序,只支持纵向方向.我想添加到仅支持横向方向的项目视图控制器?可能吗?如果是的话我怎么能实现呢?

我试图像这样包装类别文件:

@implementation UINavigationController (Rotation_IOS7)

-(BOOL)shouldAutorotate
    {

        return YES;

    }

    -(NSUInteger)supportedInterfaceOrientations
    {

      return UIInterfaceOrientationMaskLandscape;

    }
Run Code Online (Sandbox Code Playgroud)

如果我这样做,我会收到此错误:由于未捕获的异常而终止应用程序UIApplicationInvalidInterfaceOrientation,原因:Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES

uiinterfaceorientation ios

5
推荐指数
1
解决办法
7191
查看次数

AutoLayout uitableviewcell在风景和iPad上基于人像iPhone计算高度

我正在学习/试验autolayout和UITableViewCell's.我几天前问了另一个问题,我回答了我自己的问题,我仍在使用相同的约束/代码.有关完整代码,请参阅此处:AutoLayout多行UILabel切断一些文本.

要在内部缩短它heightForRowAtIndexPath我使用自定义的实例UITableViewCell来计算行需要的高度.这在肖像中工作systemLayoutSizeFittingSize得很完美,但是当我切换到横向模式时,返回的单元格高度就像是纵向一样.我打印出了contentView标签和标签的框架,似乎没有任何更新.

结果是约束迫使标签增长,留下大量的空白.标签以正确的宽度显示,在景观中它们按照我的预期布局,如果我硬编码单元格的高度,它就能完美地工作.

它看起来像这样: 在此输入图像描述

硬编码后(我希望它看起来像): 在此输入图像描述

更糟糕的是,我在iPad上运行时得到了相同的结果,甚至是肖像模式,这意味着我得到了iPhone尺寸.从我所看到的情况来看,似乎systemLayoutSizeFittingSize没有方向或设备的概念.

我试过假装frame细胞应该是,尝试旋转细胞,调用layoutSubviews,重新加载tableView方向改变,似乎没有任何影响它.

我错过了什么基本的东西?

objective-c uitableview uiinterfaceorientation ios autolayout

5
推荐指数
1
解决办法
6086
查看次数

设备处于纵向状态时获取UINavigationBar景观高度

我有一个简单的问题:我希望UINavigationBar在我的设备处于纵向状态时找出景观的高度.这是可能的,如果是的话,怎么样?

一些背景:

UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectZero];
[navBar sizeToFit];

NSLog(@"navBar: %@", NSStringFromCGRect(navBar.frame));
Run Code Online (Sandbox Code Playgroud)

这将返回正确的高度为当前设备的方向,例如44.这意味着,UINavigationBarsizeToFit方法必须以某种方式看待当前设备的方向.有没有什么方法可以找到景观中的高度而不去景观?

uinavigationbar orientation uiinterfaceorientation ios landscape-portrait

5
推荐指数
1
解决办法
1319
查看次数

使用TouchID身份验证的方向问题(格局)

我们正在为我们的iPad应用程序使用TouchID,它支持纵向和横向方向.根据我们的理解,TouchID身份验证对话框不支持横向,这仍然很好; 但是,在将屏幕切换到横向模式时,TouchID对话框仍然处于纵向模式,但是视图控制器也无法旋转到横向!此外,状态栏旋转到横向模式,给人一种难看的外观.

我们也在iTunes上观察到了类似的行为.如果这是标准行为或有任何其他方法可以解决问题,请提供建议.

uiinterfaceorientation ios touch-id

5
推荐指数
1
解决办法
550
查看次数

横向iOS 9的初始界面定位

技术说明TN2244:在横向状态下启动iPhone应用程序:

UISupportedInterfaceOrientations键的值确定应用程序启动时状态栏的位置.在iOS 7及更低版本中,如果存在UIInterfaceOrientationPortrait值,则状态栏将始终定位为纵向.否则,状态栏将根据UISupportedInterfaceOrientations键下显示的第一个方向定位.

因此,在iOS 8中,UIInterfaceOrientationLandscape首先放入UISupportedInterfaceOrientations列表以让您的应用程序在Landscape中启动是完全可以的.

它在iOS 9中不再起作用.UIInterfaceOrientationPortrait任何位置的列表中强制应用程序以肖像开始.

有没有已知的解决方法?我需要我的应用程序从Landscape开始.

注意:使用viewControllers的supportedInterfaceOrientations()方法不是一个选项,因为它在呈现LaunchScreen后生效.

iphone orientation uiinterfaceorientation ios ios9

5
推荐指数
1
解决办法
1218
查看次数

iOS9 supportedInterfaceOrientationsForWindow停止调用

我希望在横向模式下显示1或2个UIView控制器,而在Portrait中显示其他人.为此,我在AppDelegate中实现了这个功能.

-(UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return self.orientation;
}
Run Code Online (Sandbox Code Playgroud)

在AppDelegate.h中,方向是:

@property (nonatomic, assign) UIInterfaceOrientationMask orientation;
Run Code Online (Sandbox Code Playgroud)

在我需要横向的UIViewcontroller中.我放置这个代码

-(void)viewWillAppear:(BOOL)animated
{
    self.appDelegate.orientation = UIInterfaceOrientationMaskLandscape;
}
Run Code Online (Sandbox Code Playgroud)

-(void)viewWillDisappear:(BOOL)animated
{
    self.appDelegate.orientation = UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

但是,当我去'LandscapeViewController'它工作正常,我回去,它工作正常,我再次去'LandscapeViewController'它确定,然后当我回来时,supportedInterfaceOrientationsForWindow方法停止调用.有什么理由吗?或者我在做一些奇怪的事情?

objective-c orientation uiinterfaceorientation ios

5
推荐指数
1
解决办法
2137
查看次数