标签: uiinterfaceorientation

"didRotateFromInterfaceOrientation:"未调用

嗨,我想在主视图的小视图中添加子视图控制器的视图,但是didRotateFromInterfaceOrientation:未调用子控制器,因此我可以对方向的更改进行任何更改

objective-c ipad addsubview uiinterfaceorientation

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

iPad应用程序以横向模式启动

我搜索了其他现有帖子,但没有一个满足我的要求.

这是我面临的问题,

  1. 我的应用程序支持模式,横向和纵向.
  2. 但我的第一个屏幕仅支持横向,因此应用必须从横向开始.
  3. 我已将支持的Orientation设置为所有4个选项
  4. 我已将初始界面方向设置为横向(左侧主页按钮)
  5. 在第一个屏幕的视图控制器中,我定义了以下内容

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

    {
        return (interfaceOrientation != UIInterfaceOrientationPortrait);
    }
Run Code Online (Sandbox Code Playgroud)

当我启动应用程序时,模拟器始终以纵向打开,我的视图在纵向模式下全部搞砸了,因为它仅针对景观设计.切换到横向后,设备将保持此模式.

任何人都可以帮我解决这个问题吗?

谢谢Naveen

编辑:

此信息可能会有所帮助,只有当我在Portrait中按住设备然后启动应用程序时才会遇到此问题.

这不是重复的问题,仅适用于iPhone或iPad的横向模式

横向模式仅适用于iPhone或iPad

我不希望我的应用程序仅在横向,我只希望我的应用程序的第一个屏幕只在横向.

ipad uiinterfaceorientation ios

2
推荐指数
1
解决办法
9458
查看次数

如何使用UIInterfaceOrientationMask

我一直在尝试在我的Swift代码中使用UIInterfaceOrientationMask.在Objective-C中,我会将它用作枚举,当我需要使用例如肖像蒙版时,我会UIPortraitOrientationMask在我的代码中使用,如下所示:

NSUInteger orientations = UIInterfaceOrientationMaskPortrait;
Run Code Online (Sandbox Code Playgroud)

我不太确定我应该对文档做什么,而且我无法在教程书或文档中的任何地方找到任何关于"原始选项集"的内容.在此输入图像描述

iphone uiinterfaceorientation swift ios8

2
推荐指数
1
解决办法
5943
查看次数

当我推送具有不同支持方向的控制器时,为什么 UINavigationController 不改变方向?

我的代码是如何设置的:

我使用导航控制器,带有控制方向的委托:

class NavDelegate: UINavigationControllerDelegate {
  func navigationControllerSupportedInterfaceOrientations(_ navigationController: UINavigationController) -> UIInterfaceOrientationMask {
    print("Checking orientation")
    if topViewController != nil {
      return topViewController!.supportedInterfaceOrientations
    }
    return .portrait
  }

  ...
}
Run Code Online (Sandbox Code Playgroud)

我的应用程序的主视图控制器名为 MainController,它仅限纵向:

class MainController: UIViewController {
  override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
    return .portrait
  }

  ...
}
Run Code Online (Sandbox Code Playgroud)

我有另一个控制器 PhotoController,它支持所有四个方向:

class PhotoController: UIViewController {
  override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
    return .all
  }

  ...
}
Run Code Online (Sandbox Code Playgroud)

我使用 pushViewController() 将 PhotoController 推到 MainController 之上。

问题:

每个控制器本身都能正确处理方向——当我将手机旋转到所有四个方向时 MainController 保持纵向,而 PhotoController 旋转到所有四个方向。

但是这种情况不能正常工作:

  1. 将手机横放,主控制器在屏幕上。
  2. 控制器处于肖像状态(如预期)。
  3. 将 PhotoController 推入堆栈。

我希望 …

orientation uiviewcontroller uinavigationcontroller uiinterfaceorientation

2
推荐指数
1
解决办法
1090
查看次数

UIViewController interfaceOrientation问题

像往常一样,我有一个UIViewController的子类.当我加载应用程序时,我需要调整一些我必须以编程方式放入的元素.当然,大小取决于界面方向:所以,我做了:

- (void)viewDidLoad {
  switch( [self interfaceOrientation] ) {
     case UIInterfaceOrientationPortrait:
     case UIInterfaceOrientationPortraitUpsideDown:
          NSLog(@"Portrait");
          break:
     case UIInterfaceOrientationLandscapeLeft:
     case UIInterfaceOrientationLandscapeRight:
          NSLog(@"Landscape");
          break;
  }
Run Code Online (Sandbox Code Playgroud)

但无论模拟器/设备的方向如何,即使一切都正确旋转,情况也始终是viewDidLoad/WillAppear中的Portrait.在Plist中,我添加了所有支持的方向.提示?

uiviewcontroller uiinterfaceorientation

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

在"中心"模式下,如何在UIImageView中缩放图像?(更改框架不起作用)

问题 - 在"中心"模式下,如何在UIImageView中缩放图像?(更改框架不起作用)我应该澄清一下,我希望能够以编程方式执行此操作.

我可以通过将它的框架更改为更小但是在同一个中心来缩放UIImageView,这样可以工作(我在视图上放置边框来检查),但是UIImageView中的实际图像不会改变.请记住,UIImageView模式必须"居中".

背景:我问的原因是因为我想要在方向变化之间缩放一些图像,并且它们需要居中,但是它们的视图不能具有"纵横拟合"模式,因为一些视图随着时间的推移而被旋转转换,并让它们自动缩放,因为它们旋转时发生的方向更改将无法正常工作.

iphone uiview uiimageview uiinterfaceorientation ios

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

iOS 6轮换无法正常工作

我已经覆盖了我的UINavigationController来实现这些方法:

-(BOOL)shouldAutorotate
{
    return [[self.viewControllers lastObject] shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
    return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
Run Code Online (Sandbox Code Playgroud)

现在从我的第一个视图,我在这里模态地呈现这个MSNavigationPaneViewController ,就像一个Facebook侧滑动标签栏控制器.

我需要在此处显示的1个视图控制器才能显示横向,而应用程序视图的其余部分仅为纵向.

所以在我的所有其他View控制器中,我添加了:

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotate
{
    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

在我想要的景观中我添加了:

- (BOOL)shouldAutorotate
{
    return UIInterfaceOrientationMaskLandscape;
}
-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}
Run Code Online (Sandbox Code Playgroud)

然而我的所有观点都在旋转

如果我shouldRotate在这些其他视图上更改为NO,那么它们将保留在Portrait中,并且我想要成为Landscape的视图可以旋转,但是我无法让它自行旋转.此外,一旦旋转,如果我回到另一个视图,shouldRotate = NO;然后它不能旋转回肖像.

我已经在这几个小时了,无法让它工作.

谢谢

编辑-----

我现在正在这一半工作,并开始一个新问题,让自动旋转在这里工作

iphone cocoa-touch uiinterfaceorientation ios

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

iOS 6旋转到Portrait Upside Down不适用于UITableViewController,iOS 5很好

我有一个应用程序,支持所有四个方向,在iOS 5上正常工作.

但是,在iOS 6上,我的所有UIViewController类都可以正常旋转,但我的UITableViewController类不会旋转到PortraitUpsideDown.

应用程序支持的方向包括所有四个选项.

AppDelegate支持所有方向:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    //return (UIInterfaceOrientationMaskAll);
    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown);
}
Run Code Online (Sandbox Code Playgroud)

我的所有视图类都实现了必要的方法,包括为iOS 6引入的方法:

- (NSUInteger)supportedInterfaceOrientations
{
    //return (UIInterfaceOrientationMaskAll);
    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown);
}

- (BOOL)shouldAutorotate
{
    BOOL bReturn = [self shouldAutorotateToInterfaceOrientation:self.interfaceOrientation];
    return (bReturn);
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (YES);
}
Run Code Online (Sandbox Code Playgroud)

我能找到的唯一区别是视图的显示方式.

的UIViewController

InfoViewController *infoController = [[InfoViewController alloc] initWithNibName:@"InfoViewController" bundle:[NSBundle mainBundle]];
[self presentModalViewController:infoController animated:YES];
Run Code Online (Sandbox Code Playgroud)

的UITableViewController …

uitableview uiinterfaceorientation ios ios6

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

U7extfield shouldChangeCharactersInRange在iOS7中将视图从纵向旋转到横向或反之亦然

当我将视图从纵向旋转到横向或从横向旋转到纵向并且尝试通过键盘输入值时,我有一个视图,其中有2个文本字段,然后什么都不会发生.在大多数情况下,它会崩溃.

它适用于iOS 6,但在iOS 7中无法正常工作.

请建议/帮助.

提前致谢.

uitextfield ipad uiinterfaceorientation ios ios7

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

如何在iOS 8中为特定控制器禁用自动旋转?

-(BOOL)shouldAutorotate {

    return NO;

}
Run Code Online (Sandbox Code Playgroud)

上面的方法适用于一个控制器,但是当堆栈上有多个viewControllers时.
我想要一个应该只在纵向模式下显示的特定控制器.

- (void) viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {

}
Run Code Online (Sandbox Code Playgroud)

我已经在iOS 8的堆栈溢出上使用了上面提到的方法,但它没有给出期望的结果.

objective-c uiinterfaceorientation ios ios8

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