Sha256: cc51c9d5462500c3f052b6156f189d699ac83cc216008c898c571c8ad3977d5d
Contents?: true
Size: 1.28 KB
Versions: 42
Compression:
Stored size: 1.28 KB
Contents
module SugarCube module Modal module_function def present_modal(view_ctlr, options={}, &block) target = options.fetch(:target, UIApplication.sharedApplication.keyWindow.rootViewController) animated = options.fetch(:animated, true) target.presentViewController(view_ctlr, animated:animated, completion:block) end def present_modal_in_nav(view_ctlr, options={}, &block) ctlr = UINavigationController.alloc.initWithRootViewController(view_ctlr) ctlr.modalTransitionStyle = UIModalTransitionStyleCoverVertical SugarCube::Modal.present_modal(ctlr, options, &block) ctlr end def dismiss_modal(options={}, &block) target = options.fetch(:target, UIApplication.sharedApplication.keyWindow.rootViewController) target.dismissViewControllerAnimated(true, completion:block) end end end class UIViewController def present_modal(view_ctlr, options={}, &block) options = options.merge(target: self) super(view_ctlr, options, &block) end def present_modal_in_nav(view_ctlr, options={}, &block) options = options.merge(target: self) super(view_ctlr, options, &block) end def dismiss_modal(view_ctlr, options={}, &block) options = options.merge(target: self) super(view_ctlr, options, &block) end end
Version data entries
42 entries across 42 versions & 1 rubygems