views:

33

answers:

1

I have a for loop that creates multiple UIImageViews that I add to self.view I do this in my custom init method.

- (id)init {
 if ( self = [super init] ) {
    for ( int i = o; i < [count]; i++ ) {    //count is a variable I am using (typicly 3)
        UIImageView *tmpImageView = [[UIImageView alloc] initWithImage[data getImage]];
        tmpImagView.tag = i;
        tmpImageView.frame = self.view.frame;
        [self.view addSubview:tmpImageView];
    }
}

In my on method I want to access this tmpImageView and change it's properties like transform and frame

- (void)otherMethod {
    //Play with the tmpImageView's properties
}

But the tmpImageView is out of scope. How do I access it. Without using an NSMutableArray

+1  A: 
- (void)otherMethod {
    UIImageView* tImageView = (UIImageView*) [self.view viewWithTag: someTag];
    //Play with the tmpImageView's properties
} 
Vladimir
Wow thanks so much I just didn't understand how to use `viewWithTag:` Thanks
Jaba
Is that view still in memory even before I were to implement this?
Jaba
yes, UIView retains its subviews so you don't need to have extra storage for them
Vladimir