/ / Xcode 8: UIView funktioniert nicht als Subview - ios, xcode, uiview, uiviewcontroller

Xcode 8: UIView funktioniert nicht als Subview - ios, xcode, uiview, uiviewcontroller

Ich habe ein UIViewController und ein Seprate UIView(MyTopView) was ich darauf zeige UIViewController. Im Xcode 8, nachdem Sie die Aufforderung "Choose intital device" ausgewählt haben, die UIView ist nicht richtig ausgerichtet UIViewController"s Aussicht.

Das ist mein UIViewController.

_ViewTop ist auch eine Containeransicht, die MyTopView enthalten wird

Bildbeschreibung hier eingeben

Und das ist mein UIView (MyTopView) Bildbeschreibung hier eingeben

Im ViewController, viewWillAppear Methode,

_myTopView = (MyTopView *)_viewTop;

NSLog(@"_myTopView: %@", _myTopView);
NSLog(@"self.view: %@", self.view);

Aber es braucht einen falschen Rahmen 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>>

Einschränkung Warnung

    (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 )>

Ich hatte erwartet, dass UIView im View-Teil des ViewControllers angezeigt wird.

Früher arbeitete es an einer anderen Version von Xcode7.

Antworten:

0 für die Antwort № 1

Irgendwo während der Initialisierung von UIView(MyTopView), vorzugsweise im bezeichneten init-Methode, setze seine translatesAutoresizingMaskIntoConstraints-eigenschaft zu false/NO.

Ex.

- (instancetype) initWithCoder: (NSCoder*) aCoder
{
if (!(self = [super initWithCoder: aCoder])) return nil;

self.translatesAutoresizingMaskIntoConstraints = NO;

return self;
}