苹果的 MultipleDetailViews 示例中调用了 numberOfRowsInSection 但未调用 cellForRowAtIndexPath

发布于 2024-09-29 22:14:00 字数 745 浏览 0 评论 0原文

如果您下载此示例 (ipad): http://developer .apple.com/library/ios/#samplecode/MultipleDetailViews/Introduction/Intro.html 并且您在 numberOfRowsInSection 和 cellForRowAtIndexPath 处设置断点,然后从横向开始,然后我有以下问题:

First:应用程序在 numberOfRowsInSection -> 中出现两次“为什么是 2 次?因为有 2 个部分......好吧,但是他们在哪里定义有 2 个部分?”

第二次:应用程序在 numberOfRowsInSection 中出现两次,然后调用 cellForRowAtIndexPath -> 这里没有问题...这是正常的

第三:当我更改为纵向模式并按下弹出按钮时,应用程序调用 numberOfRowsInSection 3 次,但从未调用过 cellForRowAtIndexPath -> “为什么 3 次?为什么他不调用 cellForRowAtIndexPath”?

提前致谢!

If you download this sample (ipad): http://developer.apple.com/library/ios/#samplecode/MultipleDetailViews/Introduction/Intro.html
and you set a breakpoint at numberOfRowsInSection and also at cellForRowAtIndexPath and you start in landscape then i have the following question:

First: the app comes twice in numberOfRowsInSection -> "why 2 times? Because there are 2 sections.. oké, but where did they define that there are 2 sections?"

Second: the app comes twice in numberOfRowsInSection and then calls cellForRowAtIndexPath -> no questions here... this is normal

Third: when i change to portrait mode and press the popoverbutton the app calls numberOfRowsInSection 3 times and never called cellForRowAtIndexPath -> "why 3 times? Why dont he call cellForRowAtIndexPath"?

Thanks in advance!

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

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

发布评论

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

评论(1

硬不硬你别怂 2024-10-06 22:14:00

从代码上看,根视图控制器中似乎只有一个部分,并且该部分有两行(tableView:numberofRowsInSection:中的注释是错误的)。

任何人都可以猜测为什么 tableView:numberOfRowsInSection: 被多次调用,而 tableView:cellForRowAtIndexPath: 没有被调用。由表视图的内部实现来确定何时需要调用这些方法来布局其内容。如果您正确地实现这些方法,那么它们被调用多少次并不重要。

From glancing at the code, it looks like there is only one section in the root view controller, and that section has two rows (the comment in tableView:numberofRowsInSection: is wrong).

It's anybody's guess as to why tableView:numberOfRowsInSection: is called multiple times, and tableView:cellForRowAtIndexPath: is not called. It's up to the internal implementation of the tableview to determine when it needs to call those methods to lay out its content. And if you implement those methods correctly, it doesn't matter how many times they're called.

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