我有一個滾動視圖作爲橫幅,包含15個圖像視圖作爲子視圖(水平滾動)。我想補充的子視圖是這樣的:滾動視圖上的子視圖的不必要的反彈
for (int i = 0; i < featuredImages.count; i++) {
CGRect frame;
frame.origin.x = self.scrollViewFeaturedImages.frame.size.width * i;
frame.origin.y = 0;
frame.size = self.scrollViewFeaturedImages.frame.size;
UIImageView *subview = [[UIImageView alloc] init];
subview.frame = frame;
[self.scrollViewFeaturedImages addSubview:subview];
}
,並據此設置contentSize:
self.scrollViewFeaturedImages.contentSize = CGSizeMake(self.scrollViewFeaturedImages.frame.size.width * featuredImages.count, self.scrollViewFeaturedImages.frame.size.height);
self.scrollViewFeaturedImages.contentInset = UIEdgeInsetsZero;
然而,鑑於出現時,第一形象似乎是有點過。
當我滾動(水平)到下一個圖像,所述間隙消失,並且當我滾動回第一圖像,該幀被已經校正。
我也禁用了BOUNCE,但我可以垂直拖動圖像。
我也試過這樣:
self.automaticallyAdjustsScrollViewInsets = NO;
沒有成功。
發生了什麼事?
如何將圖像設置爲「UIImageViews」? – Suryakant 2014-09-26 08:05:32
@SuryakantSharma [subview setImageWithURL:[NSURL URLWithString:featured.background_url]]; (setImageWithURL來自名爲SDWebImage的庫;延遲加載) subview.contentMode = UIViewContentModeScaleToFill; – hardluckbaby 2014-09-26 08:08:07
我可以假設,圖像是從URL正確加載的? – Suryakant 2014-09-26 08:38:56