lionheart / LHSKeyboardAdjusting

An easy-to-use Objective-C protocol that automatically resizes / adjusts views when a keyboard appears on iOS.
http://lionheartsw.com
Apache License 2.0
100 stars 10 forks source link

Error setting up project using interface builder / storyboards #3

Closed roiholtzman closed 10 years ago

roiholtzman commented 10 years ago

I've followed the steps in the instructions, but I got this error: Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)

and I couldn't fix it. Does anyone know how to fix it? Or does anyone have an easy way to implement this in my viewController? Thanks!

dlo commented 10 years ago

Can you paste the entire error printed in the console?

roiholtzman commented 10 years ago

here it is:

Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSIBPrototypingLayoutConstraint:0x8f84850 'IB auto generated at build time for view with fixed frame' V:|-(0)-[UIScrollView:0x8f7d750]   (Names: '|':UIView:0x8f84170 )>",
    "<NSIBPrototypingLayoutConstraint:0x8f848b0 'IB auto generated at build time for view with fixed frame' V:[UIScrollView:0x8f7d750(568)]>",
    "<_UILayoutSupportConstraint:0x8f7cb90 V:[_UILayoutGuide:0x8f7ee00(0)]>",
    "<_UILayoutSupportConstraint:0x8f7cb10 _UILayoutGuide:0x8f7ee00.bottom == UIView:0x8f84170.bottom>",
    "<NSLayoutConstraint:0x8f7cd40 UIScrollView:0x8f7d750.bottom == _UILayoutGuide:0x8f7ee00.top>",
    "<NSAutoresizingMaskLayoutConstraint:0xad6a590 h=--& v=--& V:[UIView:0x8f84170(480)]>"
)

Will attempt to recover by breaking constraint 
<_UILayoutSupportConstraint:0x8f7cb10 _UILayoutGuide:0x8f7ee00.bottom == UIView:0x8f84170.bottom>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
dlo commented 10 years ago

Can you paste any other auto layout code you're using in this view controller?

roiholtzman commented 10 years ago

I added the view controller in storyboard. I didn't specify any auto layout code, but I'm not sure if it doesn't have some auto layout business it does automatically. How can I know?

dlo commented 10 years ago

I think I see the problem. The view in your view controller isn't using auto layout if I'm reading the error above correctly. You're going to turn on autolayout and set the top, left, and right constraints in your storyboard.

roiholtzman commented 10 years ago

So if I want to have a form of some kind. and I know that when the keyboard comes up, the form doesn't fit the screen anymore. should I put this whole form inside a UIScrollView, and put the UIScrollView inside the main UIView of the viewController? if I choose to work do the form with UITableViewController, will it work?

dlo commented 10 years ago

If you're using a UITableView, you can use the table view as the resizing view since a table view is just a subclass of UIScrollView. But if you're just laying out the form elements manually (without using a table view), then yes, you'll need to embed them into a scroll view for this to really work (i.e., if you want the user to be able to scroll down to the last form if it's not visible with the keyboard showing).