colinta / teacup

This project has been sunset in favor of MotionKit
github.com/motion-kit/motion-kit
Other
602 stars 85 forks source link

Adding constraint support for topLayoutGuide #121

Closed jvonkluck closed 10 years ago

jvonkluck commented 11 years ago

I'm not sure this covers every case or that it's the most generic way to add support for the topLayoutGuide, but it's working for me.

jvonkluck commented 11 years ago

Oh so good software engineering practices are encouraged?

I'll revisit this as soon as I finish cleaning up my production app to play nice with iOS 7 and push a more thorough (tested / documented) commit.

colinta commented 11 years ago

I was getting ready to merge this, but I realized it uses sugarcube code! I like to keep these two projects separate. If I have time later I'll try and fix this, the relevant code is

def controller
  if nextResponder && nextResponder.is_a?(UIViewController)
    nextResponder
  elsif nextResponder
    nextResponder.controller
  else
    nil
  end
end

# which i think could just be inline code =>

controller = view.nextResponder
until controller.is_a?(UIViewController) || controller.nil?
  controller = view.nextResponder
end
jvonkluck commented 11 years ago

Colin -

I'm just getting back to this now. Given that you prefer to keep the projects decoupled, do have a preferred approach other than simply duplicating the logic that walks up the nextResponder chain until it hits a controller?

colinta commented 11 years ago

yeah I think duplicating that logic would be appropriate here, it's not a lot of code, I think.

jvonkluck commented 11 years ago

Please take a look and let me know if this is sufficient for a merge back into your upstream. I've added test coverage for the constraints and duplicated the small bit of logic from SugarCube to avoid a dependency.

colinta commented 11 years ago

Hi! I'm going to merge this, but in a slightly different way. I'm not a fan of having teacup simply redefine sugarcube's controller method, instead I was thinking that code could be placed IN the body of the method, as a while loop for example.

colinta commented 10 years ago

Oh my gosh, this totally fell off my radar. Sorry about that! Merged now, I removed the controller method and am using in-line code like I mentioned above.

Thanks!