UIView 翻译后的触摸问题

发布于 2024-09-18 21:00:55 字数 880 浏览 3 评论 0原文

我有 uiview“DummyView”,并在 DummyView 中并排添加了另外两个视图“StartView”和“ShowView”。

当应用程序启动时,将显示 StartView。该视图上有一个 UIButton,它会触发平移动画,将 StartView 移至左侧(屏幕外)并将 ShowView 移至屏幕中。在 ShowView 上,我有一个 UIScrollView。

翻译动画之后我无法再滚动 UIScrollView 。在将 StartView 移出屏幕之前,它工作得很好(经过测试)。

这是代码。

- (void)viewDidLoad {
    [super viewDidLoad];

    [button addTarget:self action:@selector(moveIt:) forControlEvents:UIControlEventTouchUpInside];
}


- (void)moveIt:(id)sender {
    NSLog(@"Move it!");

    [UIView beginAnimations:@"Move It" context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationBeginsFromCurrentState:YES];

    CGAffineTransform transform = CGAffineTransformMakeTranslation(-1024, 0);
    self.view.superview.transform = transform;

    [UIView setAnimationDelegate:self];
    [UIView commitAnimations];

}

谢谢你的建议。

i have uiview "DummyView" and added two other views "StartView" and "ShowView" side-by-side into the DummyView.

When the app starts the StartView shows up. On this view is a UIButton, which triggers a translation animation to move the StartView to the left (out of the screen) and the ShowView into the Screen. On the ShowView, I have a UIScrollView.

After the translation animation I can't scroll through my UIScrollView any longer. Before moving StartView out of the screen it works perfectly (tested it).

Here's the code.

- (void)viewDidLoad {
    [super viewDidLoad];

    [button addTarget:self action:@selector(moveIt:) forControlEvents:UIControlEventTouchUpInside];
}


- (void)moveIt:(id)sender {
    NSLog(@"Move it!");

    [UIView beginAnimations:@"Move It" context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationBeginsFromCurrentState:YES];

    CGAffineTransform transform = CGAffineTransformMakeTranslation(-1024, 0);
    self.view.superview.transform = transform;

    [UIView setAnimationDelegate:self];
    [UIView commitAnimations];

}

Thanks for advice.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

起风了 2024-09-25 21:00:56

动画完成后尝试:

self.view.superview.transform = CGAffineTransformIdentity;

这应该有帮助

after animation completion try:

self.view.superview.transform = CGAffineTransformIdentity;

this should help

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文