简体   繁体   中英

numberOfRowsInSection called but not cellForRowAtIndexPath in MultipleDetailViews sample of apple

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM