6
我只是有一個關於tableView的問題。節中的部分 - UITableView -
我知道我們可以返回部分和行的數量。
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
你能告訴我,我怎麼能有這樣的:
- 段內的部分(與另一部分,如果可能的話) - - 和 然後配置有行?
而且我會返回
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
聽起來很合理!我會返回numberOfSections和numberOfRowsInSection? – Legolas 2011-06-08 14:40:26
那麼假設你有3個主要部分,第1部分有3個子部分。 numberOfSections應該是3,並且當部分== 0時,您將爲numberOfRowsInSection返回行+ 3。一個用於標題和3行。並且在cellForRowAtIndexPath中,只有當indexPath.row == 0時纔會返回特殊標題行。 – vakio 2011-06-08 15:57:03
對不起,我的意思是(普通行數)+ 3個標題行。 3爲標題,然後是普通的行。您現在必須跟蹤使用標題的位置,因此,在cellForRowAtIndexPath中,您將在部分0中返回第0行,第5行和第8行的標題。這意味着您有1,2,3行的正常行, 4(子部分1),6,7(子部分2)等等。對於子子部分它將會(甚至更多)變得複雜,但是你可以使用NSDictionaries內的NSDictionaries或其他東西來生成它們的整個樹。 – vakio 2011-06-08 16:05:10