gpt4 book ai didi

ios - 将 ECSlidingViewController 与 TableView 一起使用

转载 作者:可可西里 更新时间:2023-11-01 06:18:30 25 4
gpt4 key购买 nike

我正在使用 ECSlidingViewController在我的应用程序中,它包含如下所示的 GestureRecognizer:

[self.view addGestureRecognizer:self.slidingViewController.panGesture];

它阻止了 TableView 的滚动。当我删除该行时,滚动效果很好。我的方法有什么问题?

注意:TableView 是 Navigation Controller 的一部分。我正在使用 StoryBoards

最佳答案

您需要将 UIGestureRecognizer 添加到 UINavigationController 的 View ,而不是 UITableView

一种方法是创建一个 UINavigationController 子类来处理手势识别器的创建和 ECSlidingViewController 的 underLeft(或 underRight) View Controller 的实例化:

// MyNavigationController.h
@interface MyNavigationController : UINavigationController

@end

// MyNavigationController.m
@implementation MyNavigationController

- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];

if (![self.slidingViewController.underLeftViewController isKindOfClass:[MyLeftMenuViewController class]]) {
self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"MenuViewController"];
}

[self.view addGestureRecognizer:self.slidingViewController.panGesture];
}

@end

打开 Storyboard编辑器,选择导航 Controller 并将身份检查器的自定义类字段设置为 MyNavigationController(而不是默认的 UINavigationController)。

关于ios - 将 ECSlidingViewController 与 TableView 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14433971/

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