lib/ProMotion/_ext/ViewController.rb in ProMotion-0.2.0 vs lib/ProMotion/_ext/ViewController.rb in ProMotion-0.3.0
- old
+ new
@@ -2,20 +2,67 @@
class ViewController < UIViewController
attr_accessor :screen
def viewDidLoad
super
- self.screen.view_did_load if self.screen && self.screen.respond_to?(:view_did_load)
+ if screen_will_respond_to?(:view_did_load)
+ self.screen.view_did_load
+ end
end
def viewWillAppear(animated)
super
- self.screen.view_will_appear(animated) if self.screen && self.screen.respond_to?(:view_will_appear)
+ if screen_will_respond_to?(:view_will_appear)
+ self.screen.view_will_appear(animated)
+ end
end
def viewDidAppear(animated)
super
- self.screen.view_did_appear(animated) if self.screen && self.screen.respond_to?(:view_did_appear)
+ if screen_will_respond_to?(:view_did_appear)
+ self.screen.view_did_appear(animated)
+ end
end
+ def viewWillDisappear(animated)
+ if screen_will_respond_to?(:view_will_disappear)
+ self.screen.view_will_disappear(animated)
+ end
+ super
+ end
+
+ def viewDidDisappear(animated)
+ if screen_will_respond_to?(:view_did_disappear)
+ self.screen.view_did_disappear(animated)
+ end
+ super
+ end
+
+ def screen_will_respond_to?(method)
+ self.screen && self.screen.respond_to?(method)
+ end
+
+ def shouldAutorotateToInterfaceOrientation(orientation)
+ self.screen.should_rotate(orientation)
+ end
+
+ def shouldAutorotate
+ self.screen.should_autorotate
+ end
+
+ def supportedInterfaceOrientations
+ self.screen.supported_orientations
+ end
+
+ def willRotateToInterfaceOrientation(orientation, duration:duration)
+ self.screen.will_rotate(orientation, duration)
+ end
+
+ def didRotateFromInterfaceOrientation(orientation)
+ self.screen.on_rotate
+ end
+
+ def dealloc
+ $stderr.puts "Deallocating #{self.to_s}" if ProMotion::Screen.debug_mode
+ end
end
end
\ No newline at end of file