苹果的 MultipleDetailViews 示例中调用了 numberOfRowsInSection 但未调用 cellForRowAtIndexPath
如果您下载此示例 (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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从代码上看,根视图控制器中似乎只有一个部分,并且该部分有两行(
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, andtableView: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.