iOS 9 doesn't load autolayout in layoutSubviews() as it should..
I'm tying to add shadow under a view(container) in my custom uitableviewcell, which it works good on iOS 8, but not iOS 9. But it is working when I scroll the tableview and start reusing cell.
//DidMoveToSuperview is required
- (void)didMoveToSuperview{
[super didMoveToSuperview];
[self setNeedsLayout];
[self layoutIfNeeded];
}
- (void)layoutSubviews {
[super layoutSubviews];
NSLog(@"container bound: %@", @(self.containerView.bounds.size.width));
NSLog(@"cell width: %@", @(self.frame.size.width));
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRect:self.containerView.bounds];
self.containerView.layer.masksToBounds = NO;
self.containerView.layer.shadowColor = [UIColor blackColor].CGColor;
self.containerView.layer.shadowOffset = CGSizeMake(0.0f, 5.0f);
self.containerView.layer.shadowOpacity = 0.5f;
self.containerView.layer.shadowPath = shadowPath.CGPath;
}
1st Log : container bound width on iOS 8 is OK, iOS 9 is not ok
2nd Log : cell width is Ok on iOS 8 and 9
Any clue ?