IOS7:Pop ViewController强制UIImageView丢弃 [英] IOS7: Pop ViewController forces the UIImageView to drop

查看:87
本文介绍了IOS7:Pop ViewController强制UIImageView丢弃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将我的项目升级到iOS7后

After upgrading my project to iOS7

当我执行BACK按钮并且UINavigationController返回上一页时,屏幕顶部的ImageView向下移动。

when I do a BACK Button and the UINavigationController goes back to the previous page, an ImageView on the top of the screen shifts down.

我用IB来做我的布局。这些是我的模拟指标:

I use IB to do my layouts. These are my Simulated Metrics:

我关闭了AutoLayout。关于问题可能是什么的任何想法?我不确定是否有人想看到特定的代码,我不想用太多的代码来混淆问题。

I have AutoLayout off. Any ideas on what the issue might be? I wasnt sure if anyone wants to see specific code and I didnt want to clutter up the question with too much code.

更新:根据评论问题,我想进行以下更新:

Updates: Based on the comment questions, I wanted to make these updates:


  • 在应用程序.h或.m文件中的任何位置,我都不会对imageview的大小或位置进行任何更改。

  • viewDidLoad viewDidAppear 中,我调用用户定义的方法名为 recalculateAll ,但它们根本不适用于任何图像视图尺寸。只是为了试一试,我注释掉了整个部分并运行了代码,它仍然跳了下来。

  • 在我的 init 我做的以编程方式设置一些图像视图(你看到#132看起来像是一个泡泡)使用他们的x和y。

  • In no place in the application .h or .m file do I make any changes to the imageview's sizes or location.
  • In both the viewDidLoad and viewDidAppear I call a user-defined method called recalculateAll but their is no reference at all to any imageview sizes. Just for trying it out I commented out the entire section and ran the code and it still jumps down.
  • In my init I do programatically set some imageviews (you see the #132 in what appears to be a bubble) using their x and y's.

这是我用于从视图控制器移动到tableviewcontroller的典型导航:

Here is a typical navigation I use for moving from the view controller to the tableviewcontroller:

 GetTimeOffByType *showTimeOffReport = [[GetTimeOffByType alloc] initWithNibName:@"GetTimeOffByType" bundle:nil];
    showTimeOffReport.timeOffType = @"Vacation";
    [self.navigationController pushViewController:showTimeOffReport animated:YES];

这些都是 .xib 个文件,没有故事板。它基本上是一个视图控制器,它有一个带有6个按钮的嵌入式 UINavigationController 。每按一次按钮,它就会按 UITableViewController 传递不同的参数并显示不同的数据。我用来回到原来的 UIViewController 的过渡只是iOS生成的 BACK 按钮(所以没有代码到为此而展示)

These are all .xib files, no storyboarding at all. Its basically a view controller which has an embedded UINavigationController with 6 buttons. Each time a button is pressed it pushes a UITableViewController passing different parameters and showing different data. The transition I am using to get back to the original UIViewController is simply the iOS generated BACK button (so no code to show for that)

更新#2 希望这有助于某人解决这种奇怪的行为。因此,如果我点击 showTimeOffReport 上的表格视图单元格来获取单元格细节,然后使用BACK导航一直向后它不会跳过。

Update#2 Hopefully this will help someone solve this wierd behavior. So if I were to click on the table view cell on showTimeOffReport to get the cell detail and then using BACK navigate all the way back it doesnt jump down.

更新#3 好的这是我刚刚发现的:跳下或不跳下的问题与UINavigationBar的半透明性有关。如果您有Translucent = YES,它将从窗口顶部开始。如果您有半透明= NO,它将从UINavigationBar的底部开始。

Update#3 Ok this is something I just discovered : The issue of jumping down or not is related to the translucency of the UINavigationBar. If you have a Translucent = YES it will start from the top of the window. If you have a translucent = NO it will start from the bottom of the UINavigationBar.

推荐答案

您可以尝试在UIViewController上设置新属性 edgesForExtendedLayout UIRectEdgeNone

You might try setting the new property on UIViewController edgesForExtendedLayout to UIRectEdgeNone.

这是一个很好的资源,可以解释有关iOS 7中视图布局如何变化的更多信息。

Here is a good resource that explains more about how view layouts changed in iOS 7.

请参阅Apple文档

如果您计划向后兼容,如果设备未运行iOS 7,您可能需要进行一些运行时检查并调整定位。

If you plan to be backwards compatible you will probably need to do some runtime checks and adjust positioning if the device is not running iOS 7.

这篇关于IOS7:Pop ViewController强制UIImageView丢弃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆