Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7626785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:22:20+00:00 2026-05-31T05:22:20+00:00

I have a class that subclasses ABNewPersonViewController . As I understand, when the Done

  • 0

I have a class that subclasses ABNewPersonViewController. As I understand, when the Done button in the navigation bar is clicked, the delegate method

- (void)newPersonViewController:(ABNewPersonViewController *)newPersonViewController didCompleteWithNewPerson:(ABRecordRef)person 

gets called. But before entering the delegate method, the changes will be saved to address book.

What I need is, as soon as the save button gets pressed. I need to load a UIView with 2 buttons asking the user,

  1. whether he wants the changes and
  2. whether he should abort the changes made,

But this should be done before the changes are reflected in the address book. And only on the click of the first button in the UIView, that the changes should be saved in the address book.

On the click of the 2nd button, the view should disappear and I should return to the view controller class from where the UIView is loaded.

My question is, how will I load the view on save button click, before the changes are reflected in the address book

I have created a custom save button

UIBarButtonItem *okBtn =  self.navigationItem.rightBarButtonItem;
UIBarButtonItem *saveBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:okBtn.target action:okBtn.action];
self.navigationItem.rightBarButtonItem =saveBtn;
[saveBtn release];

On the save button action, the control goes to the delegate method

 - (void)newPersonViewController:(ABNewPersonViewController *)newPersonViewController didCompleteWithNewPerson:(ABRecordRef)person`  .

I want the control go to my custom method, where I can load my UIView before the edits are saved in the address book.

Edit:
When I load the ABNewPersonViewController

 ABPersonViewController *displayVcardViewController = (ABPersonViewController*)[self.navigationController visibleViewController];

ABRecordRef person = displayVcardViewController.displayedPerson;

EditAddressNewPersonDetailViewController *newVCardViewController = [[EditAddressNewPersonDetailViewController alloc] init];
newVCardViewController.displayedPerson = person;
newVCardViewController.newPersonViewDelegate = self;
newVCardViewController.isEditingMode = YES;

[self.navigationController setToolbarHidden:YES];
[self.navigationController pushViewController:newVCardViewController animated:YES];
[newVCardViewController release];

Isn’t this strong reference already or else Where should I include the strong reference.

On

- (void)actionSave:(UIBarButtonItem *)sender {

if([[NSBundle mainBundle] loadNibNamed:@"MyView" owner:self options:nil]) { 
    [self.myView setFrame:CGRectMake(0, 0, 320, 480)];

    [[UIApplication sharedApplication].keyWindow addSubview:self.myView];

           UIActionSheet * action = [[UIActionSheet alloc]initWithTitle:@""
                                                              delegate:self
                                                     cancelButtonTitle:@"Do"
                                                destructiveButtonTitle:@"Cancel"
                                                     otherButtonTitles: nil];
           action.tag = 101; 
          [action showInView:self.view];
          [action release];
}

}

I am loading a UIView with UIAlertView over it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:22:20+00:00Added an answer on May 31, 2026 at 5:22 am

    Update: Starting with iOS 7.0, ABNewPersonViewController is not subclassable anymore and this won’t work.

    First, keep a reference to the default rightBarButtonItem before overriding it.
    If you’re subclassing ABNewPersonViewController, your viewDidLoad would look like:

    - (void)viewDidLoad {
        [super viewDidLoad];
    
        // Store the old button item into a custom property
        // @property (nonatomic, retain) UIBarButtonItem *defaultRightBarButtonItem;
    
        self.defaultRightBarButtonItem = self.navigationItem.rightBarButtonItem;
    
        UIBarButtonItem *saveBtn = [[UIBarButtonItem alloc] 
                                    initWithBarButtonSystemItem:UIBarButtonSystemItemSave 
                                    target:self 
                                    action:@selector(actionSave:)];
        self.navigationItem.rightBarButtonItem = saveBtn;
        [saveBtn release];
    }
    

    And you call the default action on the default target in your custom action method:

    - (void)actionSave:(UIBarButtonItem *)sender {
    
        // Do what you want to do before the data is saved
        // ....
        // ....
    
        // Trigger the default action
        [self.defaultRightBarButtonItem.target 
         performSelector:self.defaultRightBarButtonItem.action
         withObject:self.defaultRightBarButtonItem.target];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a base class with a virtual method, and multiple subclasses that override
I have a base class that has an abstract getType() method. I want subclasses
I have a class that subclasses NSMutableArray. I init it using: MyClass class =
I have a basic class that derived subclasses inherit from, it carries the basic
I have class method that returns a list of employees that I can iterate
Suppose I have a MyException class that subclasses Exception. I'm using this class to
I'm working on a project in swing, and I have a class that subclasses
I have a base class and several subclasses derived from that base class. I
I have a class that subclasses the list object. Now I need to handle
I have a class(parent class) that has three subclasses(class a, class b, class c).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.