IOS7: Pop ViewController forces the UIImageView to drop

会有一股神秘感。 提交于 2019-12-20 04:06:59

问题


After upgrading my project to iOS7

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.

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

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:

  • 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.

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];

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)

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.

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.


回答1:


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

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

See Apple Documentation

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.




回答2:


This might help you..You can try adding UIViewControllerBasedStatusBarAppearance key and set it's value NO in your info.plist

UIViewControllerBasedStatusBarAppearance = NO


来源:https://stackoverflow.com/questions/20258933/ios7-pop-viewcontroller-forces-the-uiimageview-to-drop

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!