我的应用程序会显示一个ABPersonViewController,并为用户提供编辑选项或选择联系人。我可以轻松地允许编辑(pvc.allowsEditing = YES
),但我无法弄清楚如何添加“选择”按钮。我更喜欢将它作为自定义按钮添加到ABPersonViewController,如Text Message等默认按钮。
答案 0 :(得分:0)
我最终继承了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];
}
答案 1 :(得分:0)