I have a UIViewController
and a seprate UIView(MyTopView)
which I am showing on that UIViewController
. In Xcode 8
, after resolving that "Choose intital device" prompt the UIView
is not aligning properly in that UIViewController's
View.
This is my UIViewController
.
Also, _viewTop is a container view which will hold MyTopView
And this is my UIView
(MyTopView)
In ViewController
, viewWillAppear
method,
_myTopView = (MyTopView *)_viewTop;
NSLog(@"_myTopView: %@", _myTopView);
NSLog(@"self.view: %@", self.view);
But it takes incorrect frame for UIView
(MyTopView)
_myTopView: <MyTopView: 0x7f9f5b5089f0; frame = (0 0; 625 832); autoresize = RM+BM; layer = <CALayer: 0x6080002230c0>>
self.view: <UIView: 0x7f9f5b5084f0; frame = (0 0; 414 736); autoresize = W+H; layer = <CALayer: 0x608000223080>>
Constraints warning
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x608000089560 h=-&- v=-&- UIView:0x7fc4c0408da0.height == MyTopView:0x7fc4c0604780.height - 832 (active)>",
"<NSLayoutConstraint:0x608000088a20 V:|-(20)-[UIView:0x7fc4c0409c90] (active, names: '|':UIView:0x7fc4c0408da0 )>",
"<NSLayoutConstraint:0x608000088ed0 V:[UIView:0x7fc4c0409c90]-(20)-| (active, names: '|':UIView:0x7fc4c0408da0 )>",
"<NSLayoutConstraint:0x608000087df0 MyTopView:0x7fc4c0604780.height == 150 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x608000088ed0 V:[UIView:0x7fc4c0409c90]-(20)-| (active, names: '|':UIView:0x7fc4c0408da0 )>
I was expecting that UIView will get displayed in that ViewController's View part.
It did used to work on ealrier version of Xcode7.
Somewhere during initialisation of UIView(MyTopView)
, preferable in the designated init
-method, set its translatesAutoresizingMaskIntoConstraints
-property to false
/ NO
.
Ex.
- (instancetype) initWithCoder: (NSCoder*) aCoder
{
if (!(self = [super initWithCoder: aCoder])) return nil;
self.translatesAutoresizingMaskIntoConstraints = NO;
return self;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.