ABPeoplePicker: Reset Custom Navigationbar Appearance - iphone

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;

Related

Disable click on background UIViewController

I am loading a ABPeoplePickerNavigationController on the click of a UITableViewCell.
self.peoplePicker = [[ABPeoplePickerNavigationController alloc] init];
self.peoplePicker.peoplePickerDelegate = self;
[self.peoplePicker setDelegate:self];
self.peoplePicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:self.peoplePicker animated:YES completion:nil];
When the picker is presented as UIModalPresentationFormSheet, I want to disable the UIViewController behind it. For that I could load a transparent view on presenting the picker and dismiss it when the picker is dismissed. So the tap on the viewcontroller wont work.
I would like to know if there is another way to do it, where I wouldn't require to create a new UIView and load/dismiss it.
You can setUserInteractionEnabled property on the view of the ViewController before presenting and after dismissing the Picker view.

Directly open ABPersonViewController in EDIT MODE DIRECTLY in iphone

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

Launch People Picker in viewDidLoad?

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.

Address Book in an Popover

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

How to use UIImagePickerController along with UITabBar in iPhone

I am using TabBarController in my application. In one of the view of the tabbar I am using a UIImagePickerController to pick an image.
When I add the picker as follows
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.editing = YES;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
It adds the picker, But at the time of choosing the photo, The bottom bar having the buttons "choose" and "cancel" gets hide under my tabbar. How to resolve this .
The problem is that you are using self as the navigation controller that shows the modal screen. Therefore the tab bar navigation controller does not know that a modal screen should fill the whole screen. Since the UIImagePickerController can not adjust itself to a smaller size you have to use the tab bar navigation controller to open present the modal view.
I use the following code to show a UIImagePickerController from a navigation controller that is shown inside a tabbar:
[self.navigationController presentModalViewController:picker animated:YES];
using self.navigationController instead of self as the object that presents the UIImagePickerController did the trick for me.
This works for me:
picker.delegate = currentClassViewController;
[tabBarController presentModalViewController:picker animated:YES];
Have your picker-caller class own or have access to your UITabController variable and presentModalViewController against your tabBarController.
I haven't seen this problem - I have an app that uses a UITabBar and a UIImagePickerController together, and the tab bar does not obscure the image picker.
Inside my view controller, which is one of the UITabBar's view controllers, I'm creating the image picker as such:
self.imagePicker = [[[UIImagePickerController alloc] init] autorelease];
imagePicker.allowsImageEditing = NO;
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
Seems very similar to your code, except that I'm setting the image picker as a retained property. Is your tab bar set up correctly? Is the view controller contained within the myTabBar.viewControllers array?