I am developing address book app. When user selects a user from a contact list , I want to open that record directly in EDIT mode using ABPersonViewController instead of clickng Edit button of ABPersonViewController. How can I achieve this? Thanks
Just call setEditing after the view is displayed:
ABPersonViewController *ab = [[ABPersonViewController alloc] init];
ab.allowsEditing = YES;
// customize as you see fit
[self.navigationController pushViewController:ab animated:YES];
[ab setEditing:YES animated:NO];
I tried this on the iPad from within a popover controller and that works fine.
In fact ABNewPersonViewController looks exactly like ABPersonViewController in edit mode.
I accomplished the same by doing like this:
ABRecordID personId = (ABRecordID)contact_ID;// if you want to edit a particular record and you're maintaining contact ID somewhere in your project.
ABPersonViewController *contactVC = [[ABPersonViewController alloc] init];
contactVC.personViewDelegate = self;// set your ViewController as delegate
contactVC.allowsEditing = YES; //set NO if you don't wanna allow editing
contactVC.displayedPerson = ABAddressBookGetPersonWithRecordID(addressBook, personId);
[self.navigationController presentViewController:contactVC animated:YES completion:nil];
Related
I'm currently working on a agenda part of an app. I managed to show all my events and also go to the details from it and edit it. But when I want to add an event it shows me an empty view. I should mention that I have a custom datasource for my calendar.
To edit an Event I just do this in my ViewController.
EKEventViewController *vc = [[EKEventViewController alloc] init];
vc.event = [dataSource eventAtIndexPath:indexPath];
vc.allowsEditing = YES;
[calendar.navigationController pushViewController:vc animated:YES];
This is showing me the correct VC with the correct event.
Now this is my code for adding a event.
EKEventEditViewController *addController = [[EKEventEditViewController alloc]init];
// set the addController's event store to the current event store.
addController.eventStore = self.eventStore;
addController.editing = YES;
// present EventsAddViewController as a modal view controller
[self presentModalViewController:addController animated:YES];
addController.editViewDelegate = dataSource;
But when I run it I get an empty viewController. Can anybody help me with this?
Kind regards.
I'm guessing that you didn't create the event store. I looked at Apple's demo program, and I could eliminate all but 4 lines, and still get that edit controller to show up:
#import <EventKitUI/EventKitUI.h>
#implementation ViewController
-(IBAction)doStuff:(id)sender {
EKEventEditViewController *addController = [[EKEventEditViewController alloc]init];
addController.eventStore = [[EKEventStore alloc] init];
[self presentViewController:addController animated:YES completion:nil];
}
I want to show new contact page on button click I have written this code within action button
{
ABNewPersonViewController *abnewpersonviewcontroller = [[ABNewPersonViewController alloc] init];
[self.navigationController pushViewController:abnewpersonviewcontroller animated:YES];
[newPersonController release];
}
this code succesfully reach me to the new contact page but the problem is navigation bar not shown onto the new contact page in which i can save record and also have cancel button on it kindly tell me how I can display the navigation on new contact page when I click on action button
use this
ABNewPersonViewController *abnewpersonviewcontroller = [[ABNewPersonViewController alloc] init];
self.navigationController.navigationBarHidden = NO;
[self.navigationController pushViewController:abnewpersonviewcontroller animated:YES];
[newPersonController release];
ABNewPersonViewController *picker =[ABNewPersonViewController new];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:picker];
picker.newPersonViewDelegate =self;
[self presentViewController:nc animated:YES completion:nil];
did you hide navigation bar in your application?
if yes, then you should unhide before moving to contact page........
thanks
Well you can add self.navigationController.navigationBarHidden = NO; to that pushed view controller in - (void)viewWillAppear:(BOOL)animated method to force it but it should show automatically if you didn't added extra UINavigationBar to your UINavigationController.
I am using a custom appearance of my UINavigationBar, the UIBarBattunItems and the BackButton. Additionally, I am using Apple's ABPeoplePicker to let the user choose from some contacts. My problem is that I would like to reset the appearance to the default appearance but only while the people picker is presented modally.
Does anyone know how to achieve this?
I am presenting my people picker in the following way.
//showing people picker do identify owner of the certificate
ABPeoplePickerNavigationController* picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self presentModalViewController:picker animated:YES];
Thanks in advance!
Try adding the following code before the present picker.
picker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
picker.modalPresentationStyle = UIModalPresentationOverCurrentContext;
I want to launch the contacts list people picker as soon as my app has finished loading, but the obvious thing doesn't seem to be working.
- (void)viewDidLoad {
name.hidden = NO;
name.text = #"ViewDidLoad";
ABPeoplePickerNavigationController *picker =
[[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self presentModalViewController:picker animated:YES];
[picker release];
}
The UILabel named "name" is getting set appropriately, but the people picker doesn't show.
I've got a button hooked up to instantiate the people picker when it's pressed, and that works fine.
Any suggestions?
Thanks!
viewDidLoad is not a good place for showing anything since your view is still not ready to be shown. Call it in viewWillAppear.
Does anyone have an example of tell me how I might open up the ABPeoplePickerNavigationController inside a popover. I have the NavigationController that is being used in the popover doing the opening, but it opens up full screen/modal.
Am I missing something here or will I need to write my own people picker to show it in the popover?
Thanks,
Create your UIPopoverController, then add an ABPeoplePickerNavigationController.
ABPeoplePickerNavigationController *contacts = [[ABPeoplePickerNavigationController alloc] init];
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:contacts];