I am attempting at turning some code written for Mac OS X into an iOS application. This is the working code for OS X:
// To create the images on the view:
NSRect imageRect = NSMakeRect(24+(i*80), ypos, 72, 96);
NSImageView *theImageView=[[NSImageView alloc] initWithFrame:imageRect];
[theImageView setBounds:imageRect];
[self addSubview:theImageView];
[theImageView setImage:[tCard image]];
[self.imageviews addObject:theImageView];
// To remove the images on the view:
for (NSImageView *timageview in self.imageviews) {
[timageview removeFromSuperview];
}
[self.imageviews removeAllObjects];
At the moment, I have:
//To create the image on the view
UIImageView * theImageView = [[UIImageView alloc] initWithFrame:CGRectMake(24+(i*80), ypos, 72, 96)];
[self addSubview:theImageView];
[theImageView setImage:[tCard image]];
[self.imageviews addObject:theImageView];
// To remove the images on the view:
for (UIImageView *timageview in self.imageviews) {
[timageview removeFromSuperview];
}
[self.imageviews removeAllObjects];
However! The removing of images does not work. The images are shown fine on the view, but I cannot remove them. To be totally honest, I'm not 100% sure about how the sample code completely works, but I am hacking away and trying to work it out, hence why I seem to be sort of half way there, but can't get the images to remove :'(
I appreciate your following input! Any questions or more information required let me know.
EDIT: This is how self.imageviews
is initialized:
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.imageviews = [[NSMutableArray alloc] initWithCapacity:4];
}
return self;
}