Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CNContactPickerViewController on tab bar controller

I'm using the CNContactPickerViewController to access contacts. And everything works fine until the part where I want to use this in Tabbar. In previous ios versions replacing the view by the picker worked well but in ios 9 does not show anything.

When I use this code to present view the tabbar disappears.

[self presentViewController:my_picker animated:YES completion: nil];

I want have the tabbar always visible and the contacts list inside the tab.

Using ABPeoplePickerNavigationController I replace the view with the following code and it works fine.

picker = [[ABPeoplePickerNavigationController alloc] init];

NSMutableArray *controllers = [NSMutableArray arrayWithArray [self.tabBarController viewControllers]];
int index = [controllers indexOfObject:self];

[controllers replaceObjectAtIndex: index withObject: picker];

Someone has a solution for this using?

like image 999
Tiago Inácio Avatar asked Sep 21 '15 16:09

Tiago Inácio


People also ask

How do I add a tab bar to a view controller?

Because tab bar items are used to configure the tab bar, you must configure the tab bar item of each view controller before displaying the tab bar interface. If you are using Interface Builder to assemble your interface, you can specify the title and image as described in Creating a Tab Bar Interface Using a Storyboard.

How do I associate a uitabbaritem with a view controller?

For each content view controller in your tab bar interface, you must provide a UITabBarItem object with the image and text to be displayed in the corresponding tab. You can associate tab bar items with your view controllers at any time before displaying your tab bar interface.

What is tab bar controller in uitabbarcontroller?

A tab bar controller, of class UITabBarController, is a container view controller. We typically group together 3–5 together for better organisation. We switch from views by tapping the tab bar items in the bottom bar. Let’s add a function to setup the tabs.

What is the difference between content view controller and tab bar controller?

Each content view controller manages a distinct view hierarchy, and the tab bar controller coordinates the navigation between the view hierarchies. This chapter describes how you configure and use tab bar controllers in your app.


1 Answers

Just use these lines into your code ,

my_picker.modalPresentationStyle=UIModalPresentationOverCurrentContext;              

[self presentViewController:my_picker animated:YES completion:nil]; 

Now the tabBar won't disappear from your screen

like image 146
Ranjani Avatar answered Oct 20 '22 20:10

Ranjani