I\'m trying to solve a view placement bug that has arisen as of iOS 9. I am instantiating a view controller from a xib file (non-autolayout) and then pushing this onto my
Try moving the layout code from viewWillAppear
to viewWillLayoutSubviews
.
I am also looking for the best fix.
My temporary one is to call the code that was in "viewDidAppear" in "viewDidLayoutSubviews". That way, my code will get called as soon as the frames are set.
But, make sure to add a boolean or something so that your code doesn't get called every time viewDidLayoutSubviews is called
-(void)viewDidLayoutSubviews{
if (didLayoutSubviews == NO){
didLayoutSubviews = YES;
// perform code that was in viewWillAppear
}
}
A little bit updated NickProvost's answer:
private var loadViewToken: dispatch_once_t = 0
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
dispatch_once(&loadViewToken) { [weak self] in
if let wSelf = self {
wSelf.setupView()
}
}
}
I occurred this issue too,
try to uncheck option "Resize View From NIB" from storyboard