I'm using iCarousel
in my objective-c
application. Each carousel view
contains an image
. So in the
-(UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view
I set the image
like that:
[carouselImage setImageWithURL:[NSURL URLWithString:myStringUrl] placeholderImage:[UIImage imageNamed:placeholderImage]];
The application crash in this line. And this is the error:
-[CarouselUIView setImageWithURL:placeholderImage:]: unrecognized selector sent to instance
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CarouselUIView setImageWithURL:placeholderImage:]: unrecognized selector sent to instance 0x123d10a70'
When I searched about that I found that many solutions suggest the use of the -ObjC
flag iin the Build Settings
but I have already this flag.
Edit: Additional code
This is the whole code of my function:
-(UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view {
UIImageView * carouselImage;
if (view == nil) {
NSData *tempArchiveView = [NSKeyedArchiver archivedDataWithRootObject:self.carouselItemView];
CarouselUIView * carousselView = [NSKeyedUnarchiver unarchiveObjectWithData:tempArchiveView];
view = carousselView;
}
carouselImage = (UIImageView *) [view viewWithTag:0];
[carouselImage setImageWithURL:[NSURL URLWithString: myStringUrl] placeholderImage:[UIImage imageNamed:imagePlaceholder]];
return view;
}
And the CarouselView
:
#import <UIKit/UIKit.h>
@interface CarouselUIView : UIView
@property (weak, nonatomic) IBOutlet UIImageView * carouselImage;
@end
From looking to your given code the line you used to init the view with imageView has issue.
[view viewWithTag:0];
Must change tag value to other then 0. As all view's tag property is set to 0 by default.
Happy coding :)