Search code examples
iphonecalluitabbaruitabbaritem

Start iphone call from tab bar item


i'm sorry for my english.

I'm trying to develop an app and in one of my tab bar item i want provide the functionality to start a phone call.

I know that is possible to start a call with the following code that i found in another topic:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:12125551212"]]; 

Is possible integrate this method in a "tab bar item"?


Solution

  • You can use

    - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
    

    and check the viewController.tabBarItem and even return NO to not select view controller and only initiate the call

    UITabBarControllerDelegate