I have a view controller that was written back in the days of iOS 5 and I'm trying to transition it to iOS 7. After reading the iOS 7 transition guide and poking around on SO, I discovered that I need to set the new iOS 7 property edgesForExtendedLayout to UIRectEdgeNone to prevent one of my custom subviews from appearing 49 pixels higher on iOS 7 than it appears on iOS 6. However, after setting that property, my custom subview is still appearing 49 pixels higher on iOS 7 and I don't know what else I need to do. Here's my simple code that I added to my viewDidLoad method...
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
and here's the code for creating and adding the custom subview that is appearing higher on iOS 7...
CGRect customControlFrameRect = {{0.0f, 240.0f}, {100.0f, 100.0f}};
self.customControl = [[MyCustomControl alloc] initWithFrame:customControlFrameRect];
self.customControl.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
[self.view addSubview:self.customControl];
One other important detail, if it helps, is this view is created from a nib file, but the custom subview that is appearing higher on iOS 7 than iOS 6 is the only subview that is created and added programmatically in viewDidLoad, after I set the edgesForExtendedLayout property. All the other subviews that are created from the nib aren't affected regardless of the whether or not I set the egdesForExtendedLayout property.
My two questions are...
- Why is my custom subview appearing higher on iOS 7 even after I set the edgesForExtendedLayout property to UIRectEdgeNone?
- Why aren't the other subviews (the subviews that are loaded from the nib) appearing higher in iOS 7?
Thanks in advance for your wisdom!