Skip to content

Instantly share code, notes, and snippets.

@imrekel
Last active October 12, 2015 06:58
Show Gist options
  • Save imrekel/3988983 to your computer and use it in GitHub Desktop.
Save imrekel/3988983 to your computer and use it in GitHub Desktop.
bme-ios - TouchCity
UIStoryboard* storyboard = [UIStoryboard
storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
TCBuildingInfoViewController* infoVC = [storyboard
instantiateViewControllerWithIdentifier:@"BuildingInfoViewController"];
infoVC.building = _selectedBuilding;
UIPopoverController* popover =
[[UIPopoverController alloc] initWithContentViewController:infoVC];
infoVC.popover = popover;
[popover presentPopoverFromRect:_selectedBuilding.frame inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
- (IBAction)handleLongPress:(UILongPressGestureRecognizer *)sender
{
if (sender.state == UIGestureRecognizerStateBegan)
{
CGPoint touchPoint = [sender locationInView:self.scrollView];
TCBuilding* building =
[[TCBuilding alloc] initWithBuildingType:self.buildingType];
building.center = touchPoint;
[self.scrollView addSubview: building];
}
}
- (IBAction)handlePinch:(UIPinchGestureRecognizer *)sender
{
CGFloat scaleFactor = [(UIPinchGestureRecognizer *)sender scale];
CGAffineTransform scaleTransfrom =
CGAffineTransformMakeScale(scaleFactor, scaleFactor);
CGAffineTransform rotationTransform =
CGAffineTransformMakeRotation(_selectedBuilding.rotation);
_selectedBuilding.transform =
CGAffineTransformConcat(scaleTransfrom, rotationTransform);
if (sender.state == UIGestureRecognizerStateEnded)
{
_selectedBuilding.bounds =
CGRectApplyAffineTransform(_selectedBuilding.bounds,
scaleTransfrom);
_selectedBuilding.transform = rotationTransform;
[_selectedBuilding setNeedsDisplay];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment