Latest 1.0.1
Homepage https://github.com/IHEARTCOOKIES/FBCountryPickerVC
License MIT
Platforms ios 9.1
Authors

FBCountryPicker

CI Status
Version
License
Platform

FBCountryPickerVC is a custom UITableViewController subclass that provides the user with capability of selecting a country from a predefined list in order to get the corresponding calling code.

Requirements

FBCountryPickerVC is compatible with iOS 9.1+ and requires ARC to build.

Installation

FBCountryPickerVC is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'FBCountryPickerVC'

If CocoaPods isn’t to your liking, you could always drag and drop the files located in the FBCountryPickerVC folder into your own project.

Usage

Using FBCountryPickerVC is relatively straightforward. To start off with a simple example, see below:

// Present the view controller
FBCountryPickerViewController *countryPicker = [[FBCountryPickerViewController alloc] init];
countryPicker.delegate = self; // Set delegate to receive callback information whenever the user selects a country from the list
[self presentViewController:countryPicker animated:YES completion:nil];

#pragma mark - FBCountryPickerDelegate
- (void)FBCountryPicker:(FBCountryPickerViewController *)controller didSelectCountry:(CountryModel *)countryModel {
  [controller dismissViewControllerAnimated:YES completion:nil];
  NSLog(@"Selected country: %@", countryModel);
}

If you’d want FBCountryPickerVC to start at a previously selected index, you could keep a reference to what was selected before by doing something like this:

@implementation FBViewController {
  CountryModel *_lastSelected;
}

- (void)inSomeMethod {
    FBCountryPickerViewController *countryPicker = [[FBCountryPickerViewController alloc] init];
    countryPicker.delegate = self;
    countryPicker.startingSelectedCountryIndex = lastSelected ? lastSelected : [[CountryManager sharedInstance] countryForISOCode:@"US"];
    [self presentViewController:countryPicker animated:YES completion:nil];
}

#pragma mark - FBCountryPickerDelegate
- (void)FBCountryPicker:(FBCountryPickerViewController *)controller didSelectCountry:(CountryModel *)countryModel {
  [controller dismissViewControllerAnimated:YES completion:nil];
  lastSelected = countryModel;
}

For direct examples of such an approach, please see FBViewController.m located in the Example directory.

Screenshots

FBCountryPickerFBCountryPicker

License

FBCountryPickerVC is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "FBCountryPickerVC",
    "version": "1.0.1",
    "summary": "A modern country picker for iOS.",
    "description": "FBCountryPicker is a country picker for iOS allowing the end-user to select a country from a prefilled dataset and get the respective country code in return.",
    "homepage": "https://github.com/IHEARTCOOKIES/FBCountryPickerVC",
    "authors": {
        "Filip Busic": "[email protected]"
    },
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "public_header_files": "FBCountryPickerVC/Classes/Public/**/*.h",
    "private_header_files": "FBCountryPickerVC/Classes/Private/**/*.h",
    "source_files": "FBCountryPickerVC/Classes/**/*",
    "source": {
        "git": "https://github.com/IHEARTCOOKIES/FBCountryPickerVC.git",
        "tag": "1.0.1"
    },
    "screenshots": [
        "https://github.com/IHEARTCOOKIES/FBCountryPickerVC/raw/master/1.png",
        "https://github.com/IHEARTCOOKIES/FBCountryPickerVC/raw/master/2.png"
    ],
    "platforms": {
        "ios": "9.1"
    },
    "resources": "FBCountryPickerVC/Assets/*",
    "prefix_header_file": "FBCountryPickerVC/Include/FBCountryPickerVC-prefix.pch",
    "module_name": "FBCountryPickerVC"
}

Pin It on Pinterest

Share This