Skip to content

Instantly share code, notes, and snippets.

@gfodor
Created January 19, 2013 22:28
Show Gist options
  • Save gfodor/4575605 to your computer and use it in GitHub Desktop.
Save gfodor/4575605 to your computer and use it in GitHub Desktop.
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
@nav = UINavigationController.alloc.init
@window.rootViewController = @nav
@window.makeKeyAndVisible
image_picker = UIImagePickerController.alloc.init
image_picker.sourceType = UIImagePickerControllerSourceTypeCamera
image_picker.mediaTypes = [KUTTypeImage]
image_picker.allowsEditing = false
image_picker.delegate = self
@nav.presentViewController(image_picker, animated:true, completion: → {})
true
end
def imagePickerController(picker, didFinishPickingMediaWithInfo:info)
# Closure captures and retains info
@nav.dismissViewControllerAnimated(true, completion:lambda do end)
# uncomment line below (and comment line above) to remove leak
# @nav.dismissViewControllerAnimated(true, completion:nil)
end
def imagePickerControllerDidCancel(picker)
@nav.dismissViewControllerAnimated(true, completion:nil)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment