Reputation:
- (void)viewDidLoad
{
CGRect frame = CGRectMake(20, 45, 140, 21);
UILabel *label = [[UILabel alloc] initWithFrame:frame];
[window addSubview:label];
[label setText:@"Hello world"];
[label release];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
The error is: Use of underclared identifier 'window'
Upvotes: 1
Views: 157
Reputation: 8403
You could set the tag property of UIImageView
of each one of the letters and check against them on touchesMoved.
- (void)touchesMoved:(NSSet*)touches withEvent: (UIEvent*)event{
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view.superview];
switch (touch.view.tag) {
case 0:
a.center=location;
break;
case 1:
b.center=location;
break;
case 3:
c.center=location;
break;
}
}
Using @beryllium 's comment:
- (void)touchesMoved:(NSSet*)touches withEvent: (UIEvent*)event{
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view.superview];
touch.view.center = location;
}
Also note that you should get the images' superview location, and not from the image itself.
Upvotes: 1