ABPersonViewController 上的自定义操作

发布于 2024-08-23 16:46:02 字数 174 浏览 7 评论 0原文

我的应用程序会弹出一个 ABPersonViewController 并为用户提供编辑或选择联系人的选项。我可以轻松允许编辑(pvc.allowsEditing = YES),但我不知道如何添加“选择”按钮。我更愿意将其添加到 ABPersonViewController 作为自定义按钮,如短信等默认按钮。

My app brings up a ABPersonViewController and gives the user the option to edit, or to select the contact. I can easily allow editing (pvc.allowsEditing = YES) but I can't figure out how to add the Select button. I would prefer to add it to the ABPersonViewController as a custom button like the Text Message, etc. default buttons.

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

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

发布评论

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

评论(2

卷耳 2024-08-30 16:46:03

不,你不能。对 ABPersonContact 默认外观的任何修改都将被 Apple 拒绝。另一种方法是自定义您自己的 ViewController 并从联系人加载数据。

No, you can't. Any modifications on the default appearance of ABPersonContact will be rejected by Apple. An alternative way is to custom your own ViewController and load data from Contact.

帅冕 2024-08-30 16:46:02

我最终对 ABPersonViewController 进行了子类化,并在它出现后在 UIToolbar 中滑动。示例如下:

- (void)showToolbar
{
// build the toolbar items
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
NSString* buttonTitle = NSLocalizedString(@"Select This Contact",@"button to select a contact");
UIBarButtonItem *chooseItem = [[UIBarButtonItem alloc] initWithTitle:buttonTitle
                                                               style:UIBarButtonItemStyleDone 
                                                              target:self 
                                                              action:@selector(chooseContact)];

// slide in the toolbar
self.navigationController.toolbar.barStyle = UIBarStyleDefault;
[self.navigationController setToolbarHidden:NO animated:YES];
self.navigationController.toolbar.items = [NSArray arrayWithObjects:spaceItem, chooseItem, nil];
[spaceItem release];
[chooseItem release];
}


- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController setToolbarHidden:YES animated:animated];
}

- (void)viewDidAppear:(BOOL)animated 
{
[self showToolbar];
[super viewDidAppear:animated];
}

I ended up subclassing ABPersonViewController and sliding in a UIToolbar after it appears. An example is below:

- (void)showToolbar
{
// build the toolbar items
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
NSString* buttonTitle = NSLocalizedString(@"Select This Contact",@"button to select a contact");
UIBarButtonItem *chooseItem = [[UIBarButtonItem alloc] initWithTitle:buttonTitle
                                                               style:UIBarButtonItemStyleDone 
                                                              target:self 
                                                              action:@selector(chooseContact)];

// slide in the toolbar
self.navigationController.toolbar.barStyle = UIBarStyleDefault;
[self.navigationController setToolbarHidden:NO animated:YES];
self.navigationController.toolbar.items = [NSArray arrayWithObjects:spaceItem, chooseItem, nil];
[spaceItem release];
[chooseItem release];
}


- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.navigationController setToolbarHidden:YES animated:animated];
}

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