dji*_*i33 12 iphone objective-c uitableview abaddressbook ios
我花了一些时间在SO上搜索这个答案,但找不到它,所以这里有:
我开始使用ABPeoplePickerNavigationController,当用户点击一个人时,他们将被带到ABPersonViewController,在那里他们将能够选择电话号码和电子邮件地址.完成ABPersonViewController后,它们将被带回ABPeoplePickerNavigationController.非常简单的东西.
我想要的是在他们选择电话号码或电子邮件地址后,在他们在ABPeoplePickerNavigationController中选择的表格单元格中添加detailLabel.类似"选择的电子邮件和电话号码"或"选择的电话号码".
Apple的文档说:
You should not need to subclass these controllers; the expected way to modify their behavior is by your implementation of their delegate.
提供的委托方法不会处理此问题.有没有办法在没有继承自己的情况下实现这一目标?并且,如果我必须继承ABPeoplePickerNavigationController的子类,我将覆盖哪个方法来更新detailLabel?
谢谢!
Jef*_*itz 12
这段代码似乎对我有用,当用户选择一个人并添加一个复选标记时,它会抓取单元格.我猜你也可以在其他方面调整单元格.
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person{
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]];
if(cell.accessoryType == UITableViewCellAccessoryNone){
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else{
cell.accessoryType = UITableViewCellAccessoryNone;
}
[cell setSelected:NO animated:YES];
}
return NO;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3793 次 |
| 最近记录: |