我的應用程序中有一個地址簿。在那裏,有一個tableview和一個聯繫細節頁面(請參閱截圖)。當我添加一個新的聯繫人時,最近添加的聯繫人詳細信息會顯示在聯繫人詳細信息頁面中,但是如何在tableview中選擇最近添加的聯繫人。注意:聯繫人在表格視圖中按字母順序排序..在UITableview中選擇一個特定的行
-3
A
回答
0
在要選擇的單元上使用setSelected:(BOOL)selected
方法。
0
if you are maintaining contacts array then take the topmost item as the reference of your last created contact.
Or else if you are having any index of the contact then take that index and point to the array your contact is stored.
or else if your contact object or address object has the date field compare that with other records and fetch the latest one.
0
[self.tableView selectRowAtIndexPath:selectedIndexPath
animated:NO
scrollPosition:UITableViewScrollPositionNone];
set selectedIndexPath in which you want, if select top most item means,
_selectedIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
1
如果要添加你最近的陣列中的tableView的末尾,則
if (indexPath.row==[yourContactAry count]-1) {
[tableView selectRowAtIndexPath:indexPath
animated:NO
scrollPosition:UITableViewScrollPositionNone];
}
OR
如果你在的tableView添加任何地方,然後得到的索引你的數組然後獲得indexPath然後applyCode,就像。
NSInteger indexOfArry=[yourContactAry indexOfObjectIdenticalTo:yourRecentAddedRecord];
NSIndexPath *indexPath=[NSIndexPath indexPathForRow:indexOfArry inSection:section];
相關問題
- 1. Python,選擇一個特定的行
- 2. 在一個特定的選項選擇
- 3. 如何禁用UItableview中特定的計數後的行選擇
- 4. iOS5在UITableView中選擇一個NSObject = EXC_BAD_ACCESS
- 5. 通過選擇菜單選擇一個特定的行 - PHP/Mysql
- 6. 從一個表中選擇所有行,從另一個表中選擇每個行的一個特定值
- 7. 在Matlab中選擇一個矩陣的特定行
- 8. 在SFrame中選擇一個特定的行
- 9. 在PHP/MYSQL中選擇一個特定的行
- 10. 從表中選擇行從一個特定的行
- 11. 第一行從多個數組中選擇一個特定值
- 12. 在php中選擇特定的sql行
- 13. 在Gridview中選擇特定的行
- 14. 在sql中選擇特定的行號
- 15. 選擇特定行
- 16. 在一個數字中選擇一個特定的數字
- 17. 在特定OPTGROUP選擇一個值
- 18. 無法在UITableViewController中選擇UITableView的行
- 19. 如何在一個SQL行中爲特定列選擇特定值
- 20. 最後選擇行在UITableView
- 21. 根據特定列中的特定值在SAS中選擇行
- 22. UITableView pushViewController選擇行
- 23. UITableView的選擇行按鈕應該取消選擇另一行
- 24. 選擇特定的行
- 25. 在量角器中選擇一個特定的選項
- 26. 點擊一個在自定義uitableviewcell中的uibutton在uitableview中選擇多個uibuttons
- 27. 在定製的JFileChooser中,從JComboBox中選擇一個執行該特定動作
- 28. 在SAS中選擇特定行
- 29. 在SQL Server中選擇特定行
- 30. 創建一個從舊錶中選擇特定行的表
在哪裏可以使用此代碼? – user2640613
cellForRowAtIndexPath – Rajneesh071