Skip to content

Instantly share code, notes, and snippets.

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