I have made this ImageView (UIImageView) programmatically in the viewDidLoad method.
UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(110, 200, 100, 100)];
imageview.image = [UIImage imageNamed:@"imageviewImage.png"];
[self.view addSubview:imageview];
But when I create the button like this in the viewDidLoad method I can’t reference it in other methods in the same class. Let’s say I want to change the ImageView alpha to 0.0f in an IBAction method in the same class. I can’ just reference to imageview like this:
-(IBAction) button {
imageview.alpha = 0.0f;
}
What is the easiest thing to do with the ImageView if I want to reference it in another method?
PS: The ImageView has to be made programmatically.
The issue is scope. The imageView pointer you create in viewDidLoad is only accessible there. Either create a property or use a tag.
1) Create a property:
2) Or use a tag: