Custom actions on ABPersonViewController

微笑、不失礼 提交于 2019-12-02 08:59:29

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];
}

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!