UITableViewController 不会在自定义实现上滚动

发布于 2024-10-09 03:53:57 字数 620 浏览 5 评论 0原文

有很多帖子指出应该避免使用 UITableViewController。我越来越想屈服,但我正在使用与整个应用程序相关联的 CoreDataTableViewController 超类,而且我没有时间全部重写。

当然,UITableViewController 的视图不应占据整个屏幕(iPad 项目),因此我将其作为常规 UIView 实例上的子视图,并将框架设置为相当大的尺寸。那就是奇怪的事情开始发生的时候。

我将自定义类(GroupsTableViewController->CoreDataTableViewController->UITableViewController)从一切正常的测试项目复制到我当前的项目。然后我分配/初始化并 addSubview 视图。

起初,桌子会显示为空。什么给? viewWillAppear: 消息未发送。什么……?好吧,那我手动调用一下(此时我已经开始怀疑自己了)。接下来,桌子上实际上已经充满了内容,但所有的交互性都消失了。没有点击,没有滚动。

我尝试在所有内容上设置 userInteractionEnabled,但没有结果。我敢肯定,这是一件很糟糕的事情,太愚蠢了,不能坚持下去。但我却被困在这里。

有人能指出我正确的方向吗?我是否在某处忘记了代表?或者可能是一条未发送的消息?

There are numerous posts out there stating one should avoid the use of UITableViewController. More and more I want to give in, but I'm using a CoreDataTableViewController super class that's tied into the entire application, and I don't have the time to rewrite it all.

Of course, the UITableViewController's view shouldn't take up the entire screen (iPad project), so I put it as a subview on a regular UIView instance with the frame set to a pretty size. That's when weird things start to happen.

I copied my custom class (GroupsTableViewController->CoreDataTableViewController->UITableViewController) from a test-project where everything was working fine, to my current project. I then alloc/init and addSubview the view.

At first the table would show up empty. What gives? The viewWillAppear: message is not sent. What the...? Alright, then I call it manually (at this point, I'm already starting to doubt myself). Next, the table is actually filled with content, but all interactivity is gone. No taps, no scrolling.

I tried setting userInteractionEnabled on everything, but no result. This is a n00b thing, I'm sure, too silly to be stuck on. Yet here I am, stuck.

Can anyone point me to the right direction? Did I forget a delegate somewhere? Or maybe an unsent message?

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

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

发布评论

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

评论(1

不必你懂 2024-10-16 03:53:57

您遇到的一个问题是嵌套的 UIViewController 未收到正确的事件,例如 viewWillAppear:。根据苹果的指导方针,UIViewController应该填充整个屏幕而不是代表部分视图(当然UITabBarController、UINavigationController和UISplitViewController除外)。尝试将 GroupsTableViewController 设置为主控制器(如果它位于 UINavigationController 中,请尝试推送它,如果它是拆分视图,则将其设置为详细信息视图等)。如果这有效,那么有一些事件没有完成导致您出现问题。希望有帮助!

One issue you are running into is that nested UIViewControllers do not receive the proper events such as viewWillAppear:. According to apple's guidelines an UIViewController should fill the entire screen and not represent a partial view (of course with the exceptions of the UITabBarController, UINavigationController, and UISplitViewController). Try setting the GroupsTableViewController as the main controller (if it is in an UINavigationController try pushing it, if its a split view make it the details view, etc). If that works then there a some events not getting through causing your problems. Hope that helps!

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