I'm trying to get the UIImageViews to make copies of themselves after being dragged and dropped. For example: I have UIImageViews for all the letters of the alphabet.
I hooked them all up using Interface Builder, and they move independently of each other.
I pull an "A" tile (image view) from the alphabet to spell a word.
Currently, if the A is pulled out, I have no other "A" image view to use a second "A" if there are two "A's" in the word to be spelled out.
My weak attempt to create another letter tile:
Code:
for(UITouch *touch in [event allTouches])
if ([touch view] == alphabetVowelA) {
MainSpellingView *alphabetA;
CGRect alphabetAa = CGRectMake(39, 104, 70, 70);
alphabetA = [[MainSpellingView alloc] initWithFrame:alphabetAa];
[alphabetA setImage:[UIImage imageNamed:@"a.png"]];
[alphabetA setMultipleTouchEnabled:YES];
[alphabetA setUserInteractionEnabled:YES];
[self addSubview:alphabetA];
CGPoint location = [touch locationInView:self];
alphabetVowelA.center = location;
}
My code: (I only have A, B, and C move) I figure if I can get the first three letters to do what I want, I can make them all do that. So to make things easier to work with and read, you'll notice that only three of them are set up to do anything.
MainSpellingView.m
MainSpellingView.h
TheViewController.h
TheViewController.m
While this code does create another tile using the "a" image in the original location I can't get it to move since it was created after the touchesbegan: and it of course would only work once in creating the new tile.
Ultimately, I want to have a letter tile (UIImageView) regenerate a duplicate of itself in its original location, so that if I need to use another of the same letter, I can simply drag the duplicate that was made once the original "letter tile" (UIImageView) was dragged and dropped down to the "spelling" area.
Thanks in advance for any code or direction you can give me!