我正在編寫一個應用程序,我必須在兩個單元格中顯示tableview.while第一個單元格被用戶觸摸,然後它必須顯示其他一些單元格在視圖內(我不能使用導航在這裏),也是第二個單元格也可見..任何人都可以告訴我這個建議。 謝謝大家。如何顯示錶格視圖單元格,當我們需要點擊一個單元格時
0
A
回答
1
如果要插入表格視圖單元,當你點擊一個細胞,嘗試下面的代碼。
讓我們考慮你要在第0部分的位置1,2和3中插入3行。在didSelectRowAtIndexPath方法中,執行以下操作。如果我們選擇第0節(第一節)中的第0行(第一行),這些行將被插入第0節。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0 && indexPath.section == 0) {
// Create indexPaths for the rows you are going to insert
NSIndexPath *indexPath1 = [NSIndexPath indexPathForRow:1 inSection:0]];
NSIndexPath *indexPath2 = [NSIndexPath indexPathForRow:2 inSection:0]];
NSIndexPath *indexPath3 = [NSIndexPath indexPathForRow:3 inSection:0]];
// Increase the number of rows in section 0 by 3, as we are inserting 3 rows here
numberOfRowsInSectionZero = numberOfRowsInSectionZero + 3;
// Insert the rows
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath1, indexPath2, indexPath3, nil] withRowAnimation:UITableViewRowAnimationFade];
}
}
在你numberOfRowsInSection方法,你應該有類似下面的,
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section {
// some code here
if (section == 0) return numberOfRowsInSectionZero;
// some code here
}
並確保您有在的cellForRowAtIndexPath適當的代碼方法顯示在新顯示的內容行。
注意:您必須改變您的代碼,以便在單擊第0節的行0時插入的行未插入。
0
使didSelectRow一個布爾(isRowClick)變量和
集YES,然後在此線
[yourTable reloadData];
和
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if(isRowClick)
return 7;//according to you
else
return 2;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
isRowSelect=YES;
//stuff
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//stuff according to you
}
這將HEP你。
0
- 定義數據對象,例如, NSMutableDictionary
- 總是讀出這個對象的數據(對於count和你想要顯示的值)
- 在用戶點擊定義的單元格的情況下。您將刷新MutableDirectory並添加新數據。
- 重新加載TableViewController
[tableviewController.tableview reloadData];
完蛋了 歡呼西蒙
相關問題
- 1. 如何在點擊單元格時顯示tableview單元格編輯視圖?
- 2. 當點擊表格視圖單元格時緩慢加載
- 3. 表格視圖單元格內的按鈕在單元格上點擊時顯示突出顯示的狀態
- 4. 當單元格點擊時顯示細節視圖Swift分析
- 5. 當最後一個單元格顯示時添加表格單元格。在ios
- 6. 單擊突出顯示錶格視圖單元格
- 7. 如何在點擊按鈕後顯示錶格視圖單元格值?
- 8. SWTableViewCell的RightUtilityButton如何當我點擊表格單元格
- 9. 識別表格單元格,當點擊識別器時點擊
- 10. 當單擊表格單元格時,得到隱藏的div以顯示在表格單元格下方
- 11. iPhone:當選中一個表格單元格時,更改視圖
- 12. 隱藏的UIImageView,同時點擊表格視圖單元格
- 13. 我需要顯示bootstrap模式,當我點擊日曆單元格(dncalendar)
- 14. 單擊時突出顯示錶格視圖單元格,而不是發佈
- 15. 條件表視圖單元格顯示
- 16. 單擊另一個單元格時如何更改GridView單元格的圖像?
- 17. 當滾動表格視圖單元格的視圖,單元格文本更改
- 18. 如何在表格視圖單元格中顯示數據
- 19. 當單元格插入表格時,自定義表格視圖單元格內的圖像視圖消失
- 20. 單擊按鈕時獲取表格視圖單元格索引
- 21. 顯示錶格單元格不一致。
- 22. 單擊表格單元格時,手動更改表格單元格圖像視圖umageview
- 23. 點擊表格視圖單元格打開地圖與路線
- 24. 如何使一個表格單元格點擊與Ajax.ActionLink
- 25. 如何點擊表格視圖中的單元格中的圖片視圖
- 26. 滾動到最後一個表格視圖單元格顯示第一個單元格的數據
- 27. Apple如何讓我們設置我們的表格視圖單元格?
- 28. 當點擊另一個表格時取消選擇表格視圖單元格中的按鈕
- 29. Jquery隱藏/顯示多個表格單元格的表格單元格
- 30. 單擊一個單元格並突出顯示相關單元格