Benjamin
Benjamin

Reputation: 185

remove UIImageView from subview

I created UIImageViews and add it to subview. Then I add it to NSMutableArray.

So, I need delete from memory and subview object(UIImageView) in some index

[arr removeObjectAtIndex:index];

and

[arr replaceObjectAtIndex:index withObject:[NSNull null]];

don't help, because UIImageView doesn't disappear from View.

How to do this?

sorry for my English :)

Upvotes: 0

Views: 1378

Answers (2)

ymutlu
ymutlu

Reputation: 6715

I would not prefer to add them to array, just give items tag value

[imageview setTag:index++];

. And you can get views with

[self viewWithTag:index];

and remove them

[[self viewWithTag:index] removeFromSuperView];

Upvotes: 0

Valeriy Van
Valeriy Van

Reputation: 1865

[[arr objectAtIndex:index] removeFromSuperview];

Upvotes: 3

Related Questions