gpt4 book ai didi

ios - 添加为 subview ios sdk 时滑动手势不起作用

转载 作者:行者123 更新时间:2023-12-01 16:52:07 25 4
gpt4 key购买 nike

我花了整个周末试图弄清楚为什么我的手势不起作用。当我作为模型 View 呈现时,手势正在工作,但当我添加为 subview 时,手势不起作用。是否有任何理由为什么它仅在添加为 subview 时才起作用。

此代码有效:

myVC = [[FullViewController alloc] initWithNibName:@"FullViewController" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController: myVC];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:navigationController animated:YES];
navigationController.view.superview.bounds = CGRectMake(0,0,1024,724);

此代码不起作用:
myVC = [[FullViewController alloc] initWithNibName:@"FullViewController" bundle:nil];
myVC.view.frame = CGRectMake(0, 0, 1024, 724);
myNavCtrl = [[UINavigationController alloc] initWithRootViewController:myVC];
[self.view addSubview: myNavCtrl.view];
myNavCtrl.view.frame = CGRectMake(0, -20, 1024, 675);

手势识别代码:
swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeLeft:)];
[swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[self.view addGestureRecognizer:swipeLeft];

任何帮助都会被学徒。

最佳答案

在我看来, super View 不允许触摸或用户交互。无法准确说明您提供的代码片段的原因,但您可以尝试将手势识别器添加到 super View ,看看是否有效,如果不起作用,则问题出在 super View 。

它作为模态工作,因为它根本不使用其他 View 。

关于ios - 添加为 subview ios sdk 时滑动手势不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14815919/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com