Share an iOS 8.3 issue with UIImageView, which will cause flickering when scrolling inside the container view.

Background

1
2
3
4
5
6
7
8
9
10
11
12
#pragma mark - Offset Change
- (void)offsetChange:(CGPoint) offset {
float offsetY = offset.y;
if (offsetY < 0) {
/*******************
* Scalable header
******************/
CGFloat totalOffset = TableHeaderViewHeight + ABS(offsetY);
CGFloat f = totalOffset / TableHeaderViewHeight;
self.bannerView.frame = CGRectMake(-MainScreenWidth * (f - 1.0) * 0.5, offsetY, MainScreenWidth * f, totalOffset);
}
}

Solution

1
2
3
4
5
6
7
- (CGSize)intrinsicContentSize {
if (CGSizeEqualToSize(self.image.size, CGSizeZero)) {
return CGSizeZero;
} else {
return CGSizeMake(MainScreenWidth, TableHeaderViewHeight);
}
}

The simple solution which will work fine is just overwrite the intrinsicContentSize() method of UIView, and return a fixed size. enjoy the code.