1

I have one UIViewController that loads several other UIViews inside of it

INFO :

  • UIViewController don't have .xib, is only to control and load the UIViews.
  • UIViews : loaded by .xib (i'm reusing the same .xib for every UIView that i need) << Problem??
  • UIViews : Auto layout is in .xib

First I load one view and after with one action button I call again the method to load another, here the auto layout disappears... but on the first is correct (is turn on).

The method that I use to load

+ (UIView *) loadUIViewFromNibNamed:(NSString *)nibName withRestorationIdentifier:(NSString *)restorationIdentifier{
UIView *view = nil;
NSArray *items = [[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil];
for(id item in items) {
    if ([item isKindOfClass:[UIView class]] == TRUE) {
        UIView * viewTemp = item;
        if ([viewTemp.restorationIdentifier isEqualToString:restorationIdentifier]) {
            view = item;
            break;
        }
    }
}
NSAssert1(view, @"Expected nib named %@ to contain a UIView", nibName);
return view;
}

Question : Why Auto layout is only Ok on the first loaded view? Are anything that i can reset or update the auto layout.

silvaric
  • 1,668
  • 17
  • 27

0 Answers0