我有一个UIScrollView,里面有很多项,类似于facebook feed。在那个Feed中,我有一堆图像从互联网上加载。当图像被加载时,它们会淡入。问题是如果我滚动滚动视图,那么直到我的手指从滚动视图上抬起才会出现淡入的图像动画。有没有办法在滚动时更新UIScrollView视图的子视图?
-(void)loadStuff:(DipticView*)diptic{
//DipticView is a UIView subclass that holds the imageview and some other information
ConnectionManager *conman = [[ConnectionManager alloc] init];
WebImage *webimage = [diptic.item.images firstObject]; //webimage holds the imageurl and the image
[conman getImageWithURL:webimage.image_URL inBackgroundWithBlock:^(NSString *error, id image) {
webimage.image = image;
diptic.imageView.image = image;
diptic.imageView.alpha = 0;
diptic.userInteractionEnabled = NO;
[UIView animateWithDuration:.4 animations:^{
diptic.imageView.alpha = 1;
} completion:^(BOOL finished) {
diptic.userInteractionEnabled = YES;
}];
//The diptics are all subviews of the scrollview.
}];
}
答案 0 :(得分:0)
dispatch_async(dispatch_get_main_queue(), ^{
[UIView animateWithDuration:.4 animations:^{
diptic.imageView.alpha = 1;
} completion:^(BOOL finished) {
diptic.userInteractionEnabled = YES;
}];
});
但我不确定此方法是否可以与animateWithDuration一起使用。