Custom actions on ABPersonViewController

后端 未结 2 565
隐瞒了意图╮
隐瞒了意图╮ 2021-01-27 09:49

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

相关标签:
2条回答
  • 2021-01-27 10:20

    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.

    0 讨论(0)
  • 2021-01-27 10:33

    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];
    }
    
    0 讨论(0)
提交回复
热议问题