Created
May 30, 2013 13:08
-
-
Save jjaffeux/5677693 to your computer and use it in GitHub Desktop.
adress_book_copy_value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PickerViewController < UIViewController | |
def viewDidLoad | |
show_picker = UIButton.buttonWithType(UIButtonTypeRoundedRect) | |
show_picker.setTitle("show picker", forState:UIControlStateNormal) | |
show_picker.frame = [[10,10],[100,40]] | |
show_picker.addTarget(self, action: :display_picker, forControlEvents:UIControlEventTouchUpInside) | |
self.view.addSubview(show_picker) | |
end | |
def peoplePickerNavigationController(peoplePicker, shouldContinueAfterSelectingPerson:person) | |
p "peoplePickerNavigationController:shouldContinueAfterSelectingPerson" | |
p ABRecordCopyValue(person, KABPersonFirstNameProperty) | |
p ABRecordCopyValue(person, KABPersonLastNameProperty) | |
end | |
def peoplePickerNavigationController(peoplePicker, shouldContinueAfterSelectingPerson:person, property:property, identifier:identifier) | |
p "peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier" | |
p identifier | |
end | |
def peoplePickerNavigationControllerDidCancel(peoplePicker) | |
p "peoplePickerNavigationControllerDidCancel" | |
self.navigationController.dismissModalViewControllerAnimated(true) | |
end | |
private | |
def display_picker | |
@picker = ABPeoplePickerNavigationController.alloc.init | |
@picker.peoplePickerDelegate = self | |
self.navigationController.presentModalViewController(@picker, animated:true) | |
end | |
end | |
class AppDelegate | |
def application(application, didFinishLaunchingWithOptions:launchOptions) | |
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) | |
@picker_view_controller = PickerViewController.alloc.init | |
@window.rootViewController = UINavigationController.alloc.initWithRootViewController(@picker_view_controller) | |
@window.makeKeyAndVisible | |
true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment