Created
April 17, 2010 12:26
-
-
Save SquaredTiki/369509 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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