iOS sdk question: how do I cast a UIView to a UIImage View (alternativly how do I get a UIImageView from a GestureRecognzer?)
Posted
by
user439299
on Stack Overflow
See other posts from Stack Overflow
or by user439299
Published on 2010-12-26T22:43:03Z
Indexed on
2010/12/26
22:54 UTC
Read the original article
Hit count: 162
Desired end result: user taps a UIImageView and the image changes to another image (a subsequent tap returns the image to the original state)
Problem: I add a (unique) selector to a bunch of UIImageViews (in an array) and point the action at the same function - let's call this function imageTapped: for now. Here is my code so far:
-(void)imageTapped:(UITapGestureRecognizer *)tapGesture {
UIImageView *view = tapGesture.view;
// rest of code...
}
This code actually works fine but gets a warning when I run it: "Incompatible objective c types initilizing 'struct UIView *', expected 'struct UIImageView *'
Any way to get rid of this? Not sure how casting works in objective c... primitive types seem to work fine such as (int)someFloat works fine but (UIImageView)someUiView doesn't work. Like I said, code works alright when I run it but would like to get ride of the compiler warning. Any help would be awesome.... I am very new to objective c (or any non java language for that matter) so be gentle. Thanks in advance.
© Stack Overflow or respective owner