- Restatement of the problem:
A hearderview is designed for CollectionView, and this headerview is a custom myview, with a subview in this customization, and its constraints are set to Superview. Running under the combination of Xcode 6 and iOS 8, the above-mentioned Subview completely did not follow the original design constraints, but instead reset the layout itself from (0,0) to the original point. However, it is normal in the combination of IOS7 + Xcode 5/6 and IOS8 + Xcode 5.
When initializing the MyView, add:
Self.myView.translatesAutoresizingMaskIntoConstraints = YES;
-(ID) initWithFrame: (cgrect) frame{self = [Super Initwithframe:frame]; if (self) { NSLog (@ "initWithFrame"); [[NSBundle Mainbundle] loadnibnamed:@ "MyView" owner:self Options:nil]; self.myView.translatesAutoresizingMaskIntoConstraints = YES; [Self AddSubview:self.myView]; } return self;}
Translatesautoresizingmaskintoconstraints:
Returns a Boolean value that indicates whether the view's autoresizing mask is translated to constraints for the Constra int-based layout System.
Declaration
SWIFT
func translatesAutoresizingMaskIntoConstraints() -> Bool
Objective-c
- (BOOL)translatesAutoresizingMaskIntoConstraints
Return Value
YES
If the view ' s autoresizing mask is translated to constraints for the constraint-based layout system, NO
otherwise.
Discussion
If This YES
is value, the view's superview looks at the view's autoresizing mask, produces constraints that implement It, and adds those constraints to itself (the Superview).
Import Statement
import UIKit
Availability
Available in IOS 6.0 and later.
https://developer.apple.com/library/IOs/documentation/UIKit/Reference/UIView_Class/index.html#//apple_ref/occ/ Instm/uiview/translatesautoresizingmaskintoconstraints
Http://stackoverflow.com/questions/25817609/constraints-for-subview-not-working-in-ios-8-xcode-6-6a313-works-ios-7
iOS Xcode set constraints for Subview exception in iOS 8 & Xcode 6