行我怎樣才能在不同的管理行不同,不,不段的?沒有行&部分是不固定的依賴於其他class.Suppose另一個表視圖如果XXX節頭那麼它包含5行,另一段包含頭4行。節頭是在表視圖帳戶標題從其它類無段沒有在泰伯維
Q
無段沒有在泰伯維
1
A
回答
0
其真正簡單的,使用下面的tableView delegates-
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// return your another table view's array count here, on which no of sections depends.
}
// Customize the number of rows in the table view.
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// use like this
int noOfRows = 0;
if(section == 0)
{
noOfRows = x;
}
else if(section ==1)
{
noOfRows = y;
}
.
.
.
else
{
noOfRows = z;
}
return noOfRows;
}
的x,y,z是NSInteger的這裏
1
在表視圖委託方法;它具有:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return data.count;
}
和
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [data objectAtIndex:section].count;
}
您可以在這兩種方法的段數和行數。
當然,你也必須將數據配置爲二維數組。
2
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 3; or [yourarray count] // 3 sections 0,1,2
}
對於不同勢部分不同numver行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the sections.
if( section == 0) // first section with 5 rows
return [[yourarray objectAtIndex:section] count];
if( section == 1) // 2nd section with 4 rows
return [[yourarray objectAtIndex:section] count];
if( section == 2) // 3rd section with 57rows
return [[yourarray objectAtIndex:section] count];
}
0
試試這個
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section == 0){
return 5;
}
if (section == 1){
return 10;
}
//etc.
}
1
希望它能幫助:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if( section == 0)
return [array count];
if( section == 1)
return [array2 count];
if( section == 2)
return [array3 count];
}
+0
但在這裏如何動態地給這裏的值...例如: - 你有if(section == 0)。我不想在這裏硬編碼0,1,2的值。我不確定部分的總數。我們如何做到這一點,我們想要爲不同的部分動態返回行號? – 2012-05-02 14:30:15
相關問題
- 1. 泰伯維用2段
- 2. 無法顯示泰伯維
- 3. 泰伯維每次
- 4. 調用泰伯維
- 5. Spritekit - Spritenode在泰伯維
- 6. 組合框在泰伯維
- 7. 泰伯維:添加陰影
- 8. 實時泰伯維變化
- 9. iOS版 - 泰伯維渲染
- 10. 泰伯維頭問題
- 11. 泰伯維android系統
- 12. 連接到泰伯維
- 13. 麻煩與泰伯維
- 14. 泰伯維button.tag擲LLDB
- 15. 的registerClass錯誤泰伯維
- 16. 泰伯維細胞字幕
- 17. 泰伯維圓角沒有出現在底部
- 18. 問題在CGRectMake爲泰伯維在AlertView
- 19. 泰伯維應用從SQLite數據庫
- 20. 將數據載入泰伯維
- 21. 錯誤-swift-泰伯維-custome細胞
- 22. Addint的TextView到泰伯維動態
- 23. 使用自定義泰伯維節頭
- 24. 泰伯維[cell.contentview viewwithtag:]被返回nil
- 25. 一個tabBarController與NavigationController和泰伯維
- 26. 插入的CollectionView到泰伯維細胞
- 27. 如何當我們點擊泰伯維
- 28. 泰伯維創建程序是空
- 29. 發行對象爲泰伯維
- 30. 從PLIST(字典),以泰伯維
嘿,我知道,方法yar..but我不能完全做到這一點我想 – success 2012-04-20 04:55:16
我迷惑了abo呃我必須檢查的條件? – success 2012-04-20 04:57:49
看到我的答案確切答案 – Ranga 2012-04-20 05:00:42