Skip to content

Instantly share code, notes, and snippets.

@SquaredTiki
Created April 17, 2010 12:26
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/369509 to your computer and use it in GitHub Desktop.
Save SquaredTiki/369509 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];
lastTouch = [touch locationInView:self.view];
[self.view setNeedsDisplay];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
NSArray *array = [touches allObjects];
NSLog(@"%d Count, %d", array.count, array);
currentTouch = [touch locationInView:self.view];
if (CGRectContainsPoint(sub.bounds, firstTouch)) {
NSLog(@"touch in subView/contentView");
sub.frame = CGRectMake( currentTouch.x, currentTouch.y, 130.0, 21.0);
}
NSLog(@"touch moved");
lastTouch = currentTouch;
[self.view setNeedsDisplay];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
currentTouch = [touch locationInView:self.view];
if (CGRectContainsPoint(sub.bounds, firstTouch)) {
NSLog(@"touch in subView/contentView");
sub.frame = CGRectMake(currentTouch.x, currentTouch.y, 130.0, 21.0);
}
NSLog(@"touch ended");
lastTouch = currentTouch;
[self.view setNeedsDisplay];
}
- (IBAction)add:(id)sender{
InSightViewController *contentView = [[InSightViewController alloc] initWithNibName:@"SubView" bundle:[NSBundle mainBundle]];
[contentView loadView];
CGRect frame = [contentView.view frame];
frame.origin.y = 140.0f;
frame.origin.x = 175.0f;
[contentView.view setFrame:frame];
[self.view addSubview:contentView.view];
[self.view setNeedsDisplay];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment