Created
May 29, 2013 22:06
-
-
Save jjaffeux/5674221 to your computer and use it in GitHub Desktop.
adress_book.rb
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 person | |
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