I have created three UIImageViews. I then added a UITextField to each image as a subview.
When the user clicks on the text field I want to capture which UIImageView ths text field belongs to. I am trying the following code :
-(void)textFieldDidBeginEditing : (UITextField *)textField {
textField = retainedObject;
MyPicture *capture = nil;
for (UIImageView *oneView in retainedObject.superview) {
if ([oneView isMemberOfClass:[myPicture class]])
capture = (UIImageView *)oneView;
}
However I get an error that UIView may not respond to count by enumeration. It looks like the superview of the textfield is UIView rather than UIImageView perhaps ? Can anybody help solve this ?
Thanks,
Martin
A
UIView‘ssuperViewis assumed to be aUIView. However, you can still cast it as aUIImageView, and callUIImageViewmethods on it, but just make sure it will always be aUIImageViewwithout exception, as otherwise it will crash.Source: My own applications 😉