Closed gitabdelkarim closed 6 years ago
are you sure this is not related to your earlier issue to remove images? Do you have any code to share?
I don't think it's related to remove Image method, i use this method to call addImage method :
-(void) addImagesListToSlider {
for (UIImage* image in self.galleryList) {
[_slideshow addImage:image];
}
}
- (void) addImage:(UIImage*) image
{
[self.images addObject:image];
if([self.images count] == 1){
_topImageView.image = image;
}else if([self.images count] == 2){
_bottomImageView.image = image;
}
}
And this one to remove an image :
- (void) deleteImageAtIndex:(NSUInteger) index
{
[self.images removeObjectAtIndex:index];
}
This is also happening to me.
I have a collection of transparent images that I overlay on the camera. When I first load the controller I see two images overlapping. When I remove the else if statement, everything looks correctly.
@jdrobert and @gitabdelkarim -- This might be a threading code-smell. Are you using SDWebImage to download images asynchronously? Are you dispatching_async to Thread 1 / main_queue inside the SDWebImage completion block (or anywhere else you are messaging to KASlideShow itself)?
@kirualex This might be a good cause for an NSAssert that all of your methods are being called on Thread 1, since your entire class is a subclass of UIView.
In my app, images are local to the device. Nothing is downloaded.
- (void)setupSlideshow {
NSArray *filenames = filenames = @[@"overlay_swipe",
@"overlay_01",
...
@"overlay_10",
];
[self.slideshow addImagesFromResources:filenames];
[self.slideshow addGesture:KASlideShowGestureSwipe];
[self.slideshow setTransitionType:KASlideShowTransitionSlide];
}
@jdrobert To solve your issue with seeing (what I assume to be) the second image from your array displaying beneath the first--I've found that you can set the backgroundColor of slideshow.topImageView
to white. I'm attaching a screenshot of what you'll see initially, and should see whenever a transparent image is displayed with a white background set to its imageView.
In my fork of the repo, I've set the background color of slideshow.topImageView
in -setDefaultValues
(KASlideShow.m)
(void) setDefaultValues { ...
_topImageView.backgroundColor = [UIColor whiteColor]; }
@kirualex I'm thinking of making changes to this effect and submitting a pull req--I saw that starting the project with an empty image array for slideshow shows a gray-colored box where the image would be.
In the updates I can make sure default behavior along those lines is still respected when there are no images to display.
closing in favour of #45
When i have two images, they are superposed, and when i remove the block below, in "addImage" method, i get empty image in the first time :