【问题标题】:Transform the UIView instance转换 UIView 实例
【发布时间】:2013-09-16 11:04:22
【问题描述】:

我有一个观点。单击一下,它将显示文本(它是UIView 实例)。现在我想对其进行转换。转换它。但是两种情况下的接触点应该相同(在转换之后和转换之前)。这里的接触点在之后改变转型。我该怎么办?请帮助我。谢谢。提示也将不胜感激。代码:

[UIView beginAnimations:@"tap stopped" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationDelegate:self];
angle = (layer.startAngle + layer.endAngle)/2;
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
        self.transform = CGAffineTransformMakeRotation([self rotationThetaForNewTheta:90 andOldTheta:angle]);

[UIView commitAnimations];
title = [NSString stringWithFormat:@"Layer %d",i+1];
UIFont* font = [UIFont systemFontOfSize:15];
self.popup = [[SNPopupView alloc] initWithString:title withFontOfSize:font.pointSize];
[popup addTarget:self action:@selector(didTouchPopupView:)];
[popup setDelegate:self];
[popup showAtPoint:touchPoint inView:self animated:YES];

这里我添加了弹出视图。转换后,它正在改变原点。

【问题讨论】:

  • 你能显示一些代码吗,你尝试了什么?
  • 你如何检索接触点?

标签: ios uiview transform


【解决方案1】:

我猜这个问题是因为UIView 在您使用touchPoint 之前发生了变化。
您可以使用临时变量在转换之前保存touchPoint,并使用它来显示弹出窗口。

编辑::
ViewController 的视图上使用UITapGestureRecognizer 对象,保持自定义视图禁用用户交互

但是如果您需要在自定义视图上启用用户交互,那么首先找出与 ViewController 的视图相关的接触点位置,并在 ViewController 的视图上出现弹出窗口。

使用UIGestureRecognizer方法:
- (CGPoint)locationInView:(UIView *)view找到接触点。在 view 参数中传递 ViewController 的 view 以获得相对于 ViewController 的 view 的 touchPoint。

另外,使用inView 使弹出窗口出现在接触点。在这里也传递 ViewController 的视图。

【讨论】:

  • 我按照你说的尝试了在转换 UIView 之前放置弹出代码。但仍然面临同样的问题。
  • 您是如何获得接触点的?你在使用 UITapGestureRecognizer 吗?
  • 你是在其他视图中使用这个视图还是在 ViewController 的视图中作为子视图?
  • 我的项目结构:用户的视图控制器 --> 自定义 UIView --> 弹出视图...
  • 禁用用户交互到您的自定义视图,并将点击手势识别器添加到下面的视图,即。 ViewController 的视图。然后,您的方法将稍作修改。虽然如果您需要在自定义视图上进行用户交互,那么我们需要寻找其他选项。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-05-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多