Skip to content

Instantly share code, notes, and snippets.

@SquaredTiki
Created April 18, 2010 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SquaredTiki/370346 to your computer and use it in GitHub Desktop.
Save SquaredTiki/370346 to your computer and use it in GitHub Desktop.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touchDown");
UITouch *touch = [touches anyObject];
firstTouch = [touch locationInView:self.view];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSArray *array = [touches allObjects];
UITouch *specificTouch = [array objectAtIndex:0];
currentTouch = [specificTouch locationInView:self.view];
if (CGRectContainsPoint(but.frame, firstTouch)) {
NSLog(@"touch in subView/contentView");
but.frame = CGRectMake(currentTouch.x, currentTouch.y , 130.0, 21.0);
}
NSLog(@"touch moved");
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
currentTouch = [touch locationInView:self.view];
if (CGRectContainsPoint(but.frame, firstTouch)) {
NSLog(@"touch in subView/contentView");
but.frame = CGRectMake(currentTouch.x, currentTouch.y, 130.0, 21.0);
}
NSLog(@"touch ended");
}
- (IBAction)add:(id)sender{
InSightViewController *contentView = [[InSightViewController alloc] initWithNibName:@"SubView" bundle:[NSBundle mainBundle]];
[contentView loadView];
[self.view addSubview:contentView.view];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment