Mac OS X 用に記述されたコードを iOS アプリケーションに変換しようとしています。これは 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];
現時点では、私は持っています:
//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];
でも!画像の削除は機能しません。画像はビューに正常に表示されますが、削除できません。正直に言うと、サンプル コードがどのように完全に機能するかについて 100% 確信があるわけではありませんが、ハッキングして解決しようとしているので、半分ほど進んでいるように見えますが、削除する画像:'(
次の入力に感謝します。質問や必要な情報があればお知らせください。
編集:これはどのようself.imageviews
に初期化されます:
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.imageviews = [[NSMutableArray alloc] initWithCapacity:4];
}
return self;
}