在 ABPeoplePickerNavigationController 上取消选择RowAtIndexPath

发布于 2024-08-02 12:05:37 字数 375 浏览 1 评论 0原文

我在我的应用程序中将 ABPeoplePickerNavigationController 显示为选项卡。用户单击姓名,然后单击电子邮件地址,然后我对电子邮件地址执行某些操作。

之后,我希望他们选择的人和财产淡出(不突出显示)。

在普通表中,我会调用 deselectRowAtIndexPath。但是对于 ABPeoplePickerNavCont,我似乎无法访问它的表,也不知道选择了什么 indexPath,也没有用于取消选择行的 api。

在大多数应用程序中,ABPeoplePickerNavCont 都是模态使用的,因此该行仍然突出显示并不重要,因为整个事情都会被忽略。但在我的应用程序中,它不会被忽略(就像电话应用程序中的联系人选项卡一样)。

有什么想法吗?

I'm showing an ABPeoplePickerNavigationController as a tab in my app. The user clicks a name, then email address, then I do something with the email address.

Afterwards, I'd like for the person and property that they selected to fade out (not be highlighted).

In a normal table, I'd call deselectRowAtIndexPath. But with the ABPeoplePickerNavCont I don't seem to have access to it's table, nor do I know what indexPath is selected, nor is there an api for deselecting the row.

On most apps, ABPeoplePickerNavCont is used modally so it doesn't matter that the row is still highlighted 'cause the whole thing gets dismissed. But in my app it does not get dismissed (just like the contacts tab in the Phone app).

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

瑕疵 2024-08-09 12:05:37

这就是我正在做的事情......而且看起来效果很好。当您选择/取消选择某个项目时,我还会添加一个复选标记附件。让我知道你的想法。谢谢 :)

UIView *view = peoplePicker.topViewController.view;
UITableView *tableView = nil;
for(UIView *uv in view.subviews)
{
    if([uv isKindOfClass:[UITableView class]])
    {
        tableView = (UITableView*)uv;
        break;
    }
}

if(tableView != nil)
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:[tableView indexPathForSelectedRow]];

    cell.accessoryType = cell.accessoryType == UITableViewCellAccessoryNone ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;

    [cell setSelected:NO animated:YES];
}

This is what I'm doing... and it seems to work perfectly. I'm also adding a checkmark accessory when you select/deselect an item. Let me know what you think. Thanks :)

UIView *view = peoplePicker.topViewController.view;
UITableView *tableView = nil;
for(UIView *uv in view.subviews)
{
    if([uv isKindOfClass:[UITableView class]])
    {
        tableView = (UITableView*)uv;
        break;
    }
}

if(tableView != nil)
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:[tableView indexPathForSelectedRow]];

    cell.accessoryType = cell.accessoryType == UITableViewCellAccessoryNone ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;

    [cell setSelected:NO animated:YES];
}
紙鸢 2024-08-09 12:05:37

修改robby valles的答案,这就是我取消选择ABPeoplePickerNavigationController的tableview的方法:

UIView *view = peoplePicker.topViewController.view;
  UITableView *tableView = nil;
  for(UIView *uv in view.subviews)
  {
    if([uv isKindOfClass:[UITableView class]])
    {
        tableView = (UITableView*)uv;
        break;
    }
  }
if(tableView != nil)
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:[tableView indexPathForSelectedRow]];

    cell.accessoryType = cell.accessoryType == UITableViewCellAccessoryNone ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;

    [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];
}

希望这有帮助。

Modifying robby valles' answer, this is how I deselect the tableview of ABPeoplePickerNavigationController:

UIView *view = peoplePicker.topViewController.view;
  UITableView *tableView = nil;
  for(UIView *uv in view.subviews)
  {
    if([uv isKindOfClass:[UITableView class]])
    {
        tableView = (UITableView*)uv;
        break;
    }
  }
if(tableView != nil)
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:[tableView indexPathForSelectedRow]];

    cell.accessoryType = cell.accessoryType == UITableViewCellAccessoryNone ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;

    [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];
}

Hope this helps.

ぃ双果 2024-08-09 12:05:37

在没有动画的情况下关闭人员选择器,然后在没有动画的情况下再次呈现它。看起来不错。

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person{

    [self dismissModalViewControllerAnimated:NO];

    [self presentModalViewController:peoplePicker animated:NO];
        return NO;
 }

dismiss the peoplepicker without an animation, then present it again without animation. It looks good.

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person{

    [self dismissModalViewControllerAnimated:NO];

    [self presentModalViewController:peoplePicker animated:NO];
        return NO;
 }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文