gpt4 book ai didi

uinavigationcontroller - 使用 UINavigationController 滑动手势而不是 backbarbuttonitem

转载 作者:行者123 更新时间:2023-12-02 22:32:04 25 4
gpt4 key购买 nike

我环顾四周,终究找不到用滑动手势替换 backbarbuttonitem 的方法。我想向左滑动并让应用恢复到之前的 View Controller 。澄清一下,我正在使用 UINavigationController 来管理我所有的 View Controller 。有任何想法吗?或者这是不可能的?谢谢!

最佳答案

我已经解决了,现在我觉得问这个问题很愚蠢!这是我使用的代码:

我在 ViewDidLoad 函数中创建了一个滑动手势:

- (void)viewDidLoad
{
[super viewDidLoad];


// -- EDIT Added the allocation of a UIGestureRecognizer -- //
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(gotoPreviousView:)];
swipeRight.numberOfTouchesRequired = 1;
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeRight];
}

然后我简单地创建了这个...

- (void)gotoPreviousView:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}

简单!看得太深,答案就在眼前。希望如果你不知道怎么做,你会看到这个,而不是犯同样的菜鸟错误哈...

关于uinavigationcontroller - 使用 UINavigationController 滑动手势而不是 backbarbuttonitem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12070873/

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