【问题标题】:Orientation portrait and landscape mode方向纵向和横向模式
【发布时间】:2011-03-27 17:59:20
【问题描述】:

我有 2 张大徽标图片。在横向模式下一切OK。当我更改为纵向模式时,图像将一张放在另一张上。它们对于 IB 对齐来说太大了 我可以为每个方向设置不同的视图吗? 或者我该如何解决这个问题。

【问题讨论】:

    标签: iphone objective-c cocoa-touch ios uiimage


    【解决方案1】:

    更新到 saadnib 的答案。不要使用shouldAutorotateToInterfaceOrientation。此方法用于其他用途。

    你的方法是:

    - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
    

    前者在旋转发生之前调用,第二个在界面定向之后调用。

    你应该在这里替换 UIViewController 的视图,或者你也可以在这里替换不同方向的图像。

    【讨论】:

      【解决方案2】:

      使用以下代码

      - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
      

      用于当前方向并根据它更改您的图像视图框架。

      【讨论】:

      • 我也尝试在这里玩,但我想到的唯一一件事是针对不同的方向使用不同的图像
      • 是的,您必须针对不同的方向使用不同的图像。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-12
      • 1970-01-01
      相关资源
      最近更新 更多