Reputation: 225
I am currently trying to select a UIImageView
that I have created in the storyboard in my view controller.
Is there a method equivalent to android's findViewbyId
in objective c?
Upvotes: 0
Views: 149
Reputation: 7588
Use the viewWithTag
UIImageView *yourImage = (UIImageView*)[self.view viewWithTag:20];
Upvotes: 0
Reputation: 312
After creating an IBOutlet as Samantha suggested you will need to add a gesture recogniser to your UIImageView.
I would suggest adding the gesture recognizer in viewDidLoad:
-(void)viewDidLoad {
[super viewDidLoad];
UITapGestureRecognizer *singlePress = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageViewPressed)];
[singleTap setNumberOfTapsRequired:1];
[_imageView addGestureRecognizer:singleTap];
}
- (void)imageViewPressed {
//Perform imageView action here
}
Upvotes: 0
Reputation: 36
Why not just make an IBOutlet for the imageview?
Then you can just access it by something like
self.imageView
Where imageView is what you named your outlet.
Upvotes: 2