-3

我的应用程序中有一个通讯录。在那,有一个表格视图和一个联系方式页面(参考截图)。添加新联系人时,最近添加的联系人详细信息显示在联系人详细信息页面中,但是如何在表格视图中选择最近添加的联系人..?注意:联系人在表格视图中按字母顺序排序。

4

4 回答 4

1

如果您在 tableView 的末尾添加您最近的数组,那么

if (indexPath.row==[yourContactAry count]-1) {
        [tableView selectRowAtIndexPath:indexPath
                                    animated:NO
                              scrollPosition:UITableViewScrollPositionNone];
    }

或者

如果您在 tableView 中添加任何位置,则获取数组的索引,然后获取 indexPath,然后应用代码,例如。

NSInteger indexOfArry=[yourContactAry indexOfObjectIdenticalTo:yourRecentAddedRecord];
NSIndexPath *indexPath=[NSIndexPath indexPathForRow:indexOfArry inSection:section];
于 2013-08-26T09:51:17.633 回答
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];
于 2013-08-26T09:44:03.827 回答
0

setSelected:(BOOL)selected在要选择的单元格上使用方法。

于 2013-08-26T09:37:21.803 回答
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.
于 2013-08-26T09:38:31.017 回答