How to reposition view using swift in iOS? - ios

I am using story board to build ui for my application and uses swift & i have prepared below layout you can see in screen shot.
I want to hide view containing details of stop1 & place stop2 view in place of stop1 at runtime.
I am using following code to hide stop1 & update constraint of stop2
stop1Frame.hidden = true
stop2Frame.updateConstraints()
Please help me.
putting height constraint to 0 of stop1 worked but shows me below error in console.
2015-03-13 17:03:52.738 GroundSpan[5392:1777378] 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)
(
"<NSLayoutConstraint:0x7a644500 V:[UILabel:0x7a643d50'Please tap on + button to...'(63)]>",
"<NSLayoutConstraint:0x7a64cb80 V:[UIView:0x7a63aaa0(0)]>",
"<NSLayoutConstraint:0x7a64cc10 UILabel:0x7a632e20'Stop1'.top == UIView:0x7a63aaa0.topMargin>",
"<NSLayoutConstraint:0x7a64d2b0 V:[UILabel:0x7a643d50'Please tap on + button to...']-(20)-| (Names: '|':UIView:0x7a63aaa0 )>",
"<NSLayoutConstraint:0x7a64d310 V:[UILabel:0x7a632e20'Stop1']-(NSSpace(8))-[UILabel:0x7a643d50'Please tap on + button to...']>")
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7a644500 V:[UILabel:0x7a643d50'Please tap on + button to...'(63)]>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-03-13 17:03:52.739 GroundSpan[5392:1777378] 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)
(
"<NSLayoutConstraint:0x7a64cb80 V:[UIView:0x7a63aaa0(0)]>",
"<NSLayoutConstraint:0x7a64cc10 UILabel:0x7a632e20'Stop1'.top == UIView:0x7a63aaa0.topMargin>",
"<NSLayoutConstraint:0x7a64d2b0 V:[UILabel:0x7a643d50'Please tap on + button to...']-(20)-| (Names: '|':UIView:0x7a63aaa0 )>",
"<NSLayoutConstraint:0x7a64d310 V:[UILabel:0x7a632e20'Stop1']-(NSSpace(8))-[UILabel:0x7a643d50'Please tap on + button to...']>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7a64d310 V:[UILabel:0x7a632e20'Stop1']-(NSSpace(8))-[UILabel:0x7a643d50'Please tap on + button to...']>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

Create an IBOutlet to the height constraint of stop1 so you can access it in your code.
To hide stop1, set its height constraint to 0, so stop2 will move up.
#IBOutlet weak var stop1HeightConstraint: NSLayoutConstraint!
...
// in your function:
self.stop1HeightConstraint.constant = 0
UIView.animateWithDuration(0.4, animations: {
self.view.layoutIfNeeded()
})
This all assumes that you have setup your autolayout and constraints correctly.

Related

dynamical view resizing with auto layout

I have a following view hierarchy Main -> Green -> Img
The Green view has the constraints seen in image below
The Img view has the constraints seen in the image below
So when I click the Button the frame of the Green is resized, and so the Img view because of the constraints between them.
But I get an error:
2015-06-07 20:13:07.653 ZoomInZoomOut[7152:1435937] 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) (
"",
"",
"",
"
(Names: '|':UIWindow:0x7fcbd3623630 )>",
"" )
Will attempt to recover by breaking constraint
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints
to catch this in the debugger. The methods in the
UIConstraintBasedLayoutDebugging category on UIView listed in
may also be helpful. 2015-06-07 20:13:07.655
ZoomInZoomOut[7152:1435937] 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) (
"",
"",
"<_UILayoutSupportConstraint:0x7fcbd347fb60 V:[_UILayoutGuide:0x7fcbd3487f80(20)]>",
"<_UILayoutSupportConstraint:0x7fcbd347e3f0 V:|-(0)-[_UILayoutGuide:0x7fcbd3487f80] (Names:
'|':UIView:0x7fcbd3480a20 )>",
"<_UILayoutSupportConstraint:0x7fcbd347dd20 V:[_UILayoutGuide:0x7fcbd34889a0(0)]>",
"<_UILayoutSupportConstraint:0x7fcbd3481700 _UILayoutGuide:0x7fcbd34889a0.bottom == UIView:0x7fcbd3480a20.bottom>",
"",
"
(Names: '|':UIWindow:0x7fcbd3623630 )>",
"" )
Will attempt to recover by breaking constraint
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints
to catch this in the debugger. The methods in the
UIConstraintBasedLayoutDebugging category on UIView listed in
may also be helpful.
The code called when the button is clicked:
#IBAction func buttonClicked(sender: UIButton) {
zoomedView.frame.size.height += 10.0
zoomedView.frame.size.width += 10.0
zoomedView.setTranslatesAutoresizingMaskIntoConstraints(true)
zoomedView.superview?.updateConstraints()
}
From Auto Layout Tutorial Part 2: Constraints I know that this error is caused by conflicting constraints. But I didn't add any new constraints in code behind. In storyboard if I resize the Green view, I get a misplaced view which I fix by updating constraints. That is why I'm trying to achieve in code behind, but get the error from above. Could anyone explain what I'm doing wrong?

iOS, Animating view's constraints causes error "Unable to simultaneously satisfy constraints"

I am attemptin to animate one of my container view's constraints. In IB, the the view is constrained fine without errors or warnings. When I call these methods in viewDidLoad, to change the views y coordinate like so:
self.queueContainerYConst.constant += 550;
[self.view layoutIfNeeded];
I get the message for "unable to satisfy constraints...". While running the app, my animations and UI look fine, everything is appears to be constrained properly. Here is the entire message I get in the console.
2015-05-03 14:17:52.668 Streamacy[15914:3333195] 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)
(
"<NSLayoutConstraint:0x155a95c0 V:|-(614)-[UIView:0x155a83a0] (Names: '|':UIView:0x155a91b0 )>",
"<NSLayoutConstraint:0x155a95f0 V:[UIView:0x155a83a0]-(0)-| (Names: '|':UIView:0x155a91b0 )>",
"<NSLayoutConstraint:0x155af080 'UIView-Encapsulated-Layout-Height' V:[UIView:0x155a91b0(568)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x155a95f0 V:[UIView:0x155a83a0]-(0)-| (Names: '|':UIView:0x155a91b0 )>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-05-03 14:17:52.684 Streamacy[15914:3333195] 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)
(
"<NSLayoutConstraint:0x1566a2a0 UIView:0x156a1900.width == UIView:0x156a1900.height>",
"<NSLayoutConstraint:0x156a9000 V:[UIView:0x156a1900]-(32)-[UIProgressView:0x15688f30]>",
"<NSLayoutConstraint:0x156a0df0 V:[UIProgressView:0x15688f30]-(11)-[MarqueeLabel:0x156a7360'Awake']>",
"<NSLayoutConstraint:0x156a0eb0 UIView:0x1569dd90.trailingMargin == UIView:0x156a1900.trailing + 99>",
"<NSLayoutConstraint:0x156a0f10 UIView:0x156a1900.leading == UIView:0x1569dd90.leadingMargin + 99>",
"<NSLayoutConstraint:0x156a0f40 UIView:0x156a1900.top == UIView:0x1569dd90.topMargin - 46>",
"<NSLayoutConstraint:0x156a92f0 V:[UILabel:0x156a6ea0'Tycho']-(17)-[UITableView:0x1587a000]>",
"<NSLayoutConstraint:0x156a93b0 V:[MarqueeLabel:0x156a7360'Awake']-(2)-[UILabel:0x156a6ea0'Tycho']>",
"<NSLayoutConstraint:0x156a94d0 V:[UITableView:0x1587a000]-(0)-[_UILayoutGuide:0x156a8b20]>",
"<_UILayoutSupportConstraint:0x156a4cf0 V:[_UILayoutGuide:0x156a8b20(0)]>",
"<_UILayoutSupportConstraint:0x156a4810 _UILayoutGuide:0x156a8b20.bottom == UIView:0x1569dd90.bottom>",
"<NSLayoutConstraint:0x156b6070 'UIView-Encapsulated-Layout-Width' H:[UIView:0x1569dd90(320)]>",
"<NSLayoutConstraint:0x156b60a0 'UIView-Encapsulated-Layout-Height' V:[UIView:0x1569dd90(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1566a2a0 UIView:0x156a1900.width == UIView:0x156a1900.height>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-05-03 14:17:52.688 Streamacy[15914:3333195] 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)
(
"<NSLayoutConstraint:0x156a9000 V:[UIView:0x156a1900]-(32)-[UIProgressView:0x15688f30]>",
"<NSLayoutConstraint:0x156a0df0 V:[UIProgressView:0x15688f30]-(11)-[MarqueeLabel:0x156a7360'Awake']>",
"<NSLayoutConstraint:0x156a0f40 UIView:0x156a1900.top == UIView:0x1569dd90.topMargin - 46>",
"<NSLayoutConstraint:0x156a92f0 V:[UILabel:0x156a6ea0'Tycho']-(17)-[UITableView:0x1587a000]>",
"<NSLayoutConstraint:0x156a93b0 V:[MarqueeLabel:0x156a7360'Awake']-(2)-[UILabel:0x156a6ea0'Tycho']>",
"<NSLayoutConstraint:0x156a94d0 V:[UITableView:0x1587a000]-(0)-[_UILayoutGuide:0x156a8b20]>",
"<_UILayoutSupportConstraint:0x156a4cf0 V:[_UILayoutGuide:0x156a8b20(0)]>",
"<_UILayoutSupportConstraint:0x156a4810 _UILayoutGuide:0x156a8b20.bottom == UIView:0x1569dd90.bottom>",
"<NSLayoutConstraint:0x156b60a0 'UIView-Encapsulated-Layout-Height' V:[UIView:0x1569dd90(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x156a9000 V:[UIView:0x156a1900]-(32)-[UIProgressView:0x15688f30]>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
It appears that everything inside my container view gets misplaced, why?. Am I animating/changing my view improperly?
You're view is over constrained. You have a constraint of 614 to the top and 0 to the bottom of its superview, but the height of that view is 568, so those numbers don't add up. It would be better to only have one of those vertical constraints and a fixed hight for your view if that works for your purposes (that "fixed" height could be made relative to the superview's height if you ned it to adjust for different screen sizes).

Auto layout unable to satisfy constraints when activating a segue

I have a custom table view cell with constraints suggested by Auto Layout. In the storyboard all the constraints are marked with blue lines indicating that they have no errors. The tableview launches fine and the layout works but as soon as I hit the cell to activate a segue I get this:
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.
I have not added any code that adds or removes constraints to my layout. All the constraints were auto-added by Auto layout.
The error only shows up when I hit the cell which activates a segue to take the user to the next view. When I hit the back button, the tableview returns but without any constraints.
The segue is set as Show(e.g. Push) in the Attributes Inspector.
Here's the rest of the message:
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x7ff1c276fec0 UIImageView:0x7ff1c2496b40.top == UITableViewCellContentView:0x7ff1c2496630.topMargin + 15>",
"<NSLayoutConstraint:0x7ff1c276ff10 UIImageView:0x7ff1c2496b40.centerY == UITableViewCellContentView:0x7ff1c2496630.centerY>",
"<NSLayoutConstraint:0x7ff1c24c9a70 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7ff1c2496630(43.5)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7ff1c276ff10 UIImageView:0x7ff1c2496b40.centerY == UITableViewCellContentView:0x7ff1c2496630.centerY>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-01-06 11:35:58.645 FitLift[4174:130902] 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)
(
"<NSLayoutConstraint:0x7ff1c2494c00 UIImageView:0x7ff1c277c070.top == UITableViewCellContentView:0x7ff1c277bfa0.topMargin + 15>",
"<NSLayoutConstraint:0x7ff1c24a3360 UIImageView:0x7ff1c277c070.centerY == UITableViewCellContentView:0x7ff1c277bfa0.centerY>",
"<NSLayoutConstraint:0x7ff1c24b7010 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7ff1c277bfa0(43.5)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7ff1c24a3360 UIImageView:0x7ff1c277c070.centerY == UITableViewCellContentView:0x7ff1c277bfa0.centerY>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-01-06 11:35:58.646 FitLift[4174:130902] 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)
(
"<NSLayoutConstraint:0x7ff1c24c4390 UIImageView:0x7ff1c24bc880.top == UITableViewCellContentView:0x7ff1c24bc3d0.topMargin + 15>",
"<NSLayoutConstraint:0x7ff1c24c43e0 UIImageView:0x7ff1c24bc880.centerY == UITableViewCellContentView:0x7ff1c24bc3d0.centerY>",
"<NSLayoutConstraint:0x7ff1c24c7880 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7ff1c24bc3d0(43.5)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7ff1c24c43e0 UIImageView:0x7ff1c24bc880.centerY == UITableViewCellContentView:0x7ff1c24bc3d0.centerY>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
From the error log, it seems the two conflicting constraints are the image view's top constraint and centerY constraint. Choose only one--iOS is confused what value to assign to the image view's y-coordinate. Do you want the image view to be a certain distance from the top, or to be a certain distance from the superview's vertical center?
As a general rule, if you want your UI to look the way you want to, DO NOT let Xcode auto-add the constraints for you. Define it yourself. We can't really help you here because we don't know the other constraints that Xcode added but don't conflict.
Try lowering one of your vertical constraint priorities to 999 or less.
"<NSLayoutConstraint:0x174091d00 V:|-(10)-[UILabel:0x14562e580'This'] (Names: '|':UITableViewCellContentView:0x17418d5b0 )>",
"<NSLayoutConstraint:0x174091e40 UITableViewCellContentView:0x17418d5b0.bottomMargin >= UILabel:0x14562e580'This'.bottom + 200>",
"<NSLayoutConstraint:0x17408c940 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x17418d5b0(43.5)]>"
I was getting this, notice the last one, encapsulated height 43.5, I'm guessing its a default height, and if your vertical constraints don't fit within that 43.5, the error is thrown. I'm still uncertain how the self sizing cells work, but lowering priorities silenced the warning. I tested a cell shorter than the 43.5 and it also silenced it.
I had a similar problem and it was fixed by setting the tableview's estimatedRowHeight. The default 43.5 wasn't enough to even cover the fixed number of points I set (e.g., my top label in the cell was 10 points from the top of the cell, the bottom label was 10 points from the bottom, and space between rows of labels, etc.)

Issue in setting five horizontal buttons in auto layout

I am using auto layout to create five buttons at the bottom of the view.The layout looks like below where the brown colour shows the spacer view and number shows the buttons I am using.
When I set the constraints I find that for iPhone the views are not resizing and we are missing the buttons as in the below screen shot. The buttons are hidden and are not resizing.
When I run it on iPad the last spacer view is resizing and other
Also, there are some errors in the logs that i am unable to understand can see below.
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)
(
"<NSLayoutConstraint:0x7f8673d62320 H:[UIView:0x7f8673f08c40]-(398)-| (Names: '|':UIView:0x7f8673f08970 )>",
"<NSLayoutConstraint:0x7f8673d623c0 UIView:0x7f8673f08c40.leading == UIView:0x7f8673f08970.leadingMargin + 86>",
"<NSLayoutConstraint:0x7f8673d7c1e0 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7f8673f08970(414)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7f8673d623c0 UIView:0x7f8673f08c40.leading == UIView:0x7f8673f08970.leadingMargin + 86>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2014-12-29 13:00:54.932 Browser_Test[2480:60168] 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)
(
"<NSLayoutConstraint:0x7f8673d62b60 H:|-(446)-[UIView:0x7f8673d48640] (Names: '|':UIView:0x7f8673f08970 )>",
"<NSLayoutConstraint:0x7f8673d62bb0 UIView:0x7f8673f08970.trailingMargin == UIButton:0x7f8673d53450'5'.trailing + 8>",
"<NSLayoutConstraint:0x7f8673d62c00 H:[UIView:0x7f8673d48640]-(0)-[UIButton:0x7f8673d53450'5']>",
"<NSLayoutConstraint:0x7f8673d7c1e0 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7f8673f08970(414)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7f8673d62c00 H:[UIView:0x7f8673d48640]-(0)-[UIButton:0x7f8673d53450'5']>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
So can please some body suggest me whats getting wrong.
Edit:1
Edit:2
The buttons should all have pinned width. Button 1 should be set leading to the superview and trailing to spacer 1. Button 5 should be set leading to spacer 4 and trailing to the superview. Other buttons should be set leading and trailing to the adjacent spacers. All of the spacers should be set to have equal width to spacer 1.
Now, autolayout will resize the spacer views, all at the same time, to fill the available space as they don't have a specified width but the buttons do and they also have set edges (for buttons 1 and 5).

Can't add a UIView above UITableView from storyboard

I'm trying to add a UIView above UITableView, replacing the navigation bar:
And this is how the controller is structured:
Here is the console output:
2013-07-10 00:54:54.361 WeatherSX[15225:c07] 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)
(
"<NSLayoutConstraint:0x9965880 V:|-(0)-[UIView:0x9964960] (Names: '|':UIView:0x9964900 )>",
"<NSLayoutConstraint:0x99657e0 V:[UIView:0x9964960]-(NSSpace(8))-[UITableView:0x902ca00]>",
"<NSLayoutConstraint:0x9964b00 V:[UITableView:0x902ca00(469)]>",
"<NSLayoutConstraint:0x9965720 UITabBar:0x9960fd0.bottom == UIView:0x9964900.bottom>",
"<NSLayoutConstraint:0x99656e0 V:[UITableView:0x902ca00]-(0)-[UITabBar:0x9960fd0]>",
"<NSAutoresizingMaskLayoutConstraint:0x81762a0 h=--& v=--& V:[UIView:0x9964900(460)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x9964b00 V:[UITableView:0x902ca00(469)]>
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.
What is the problem? Never faced such error before.
Thank you for helping.
You need to remove AutoLayout inside of Storyboard. Select the viewController and then select the far left tab. Remove the check mark next to AutoLayout. And then you won't have anymore constraint errors!
Step 1)
Create a header view as, Add this view on Window not view controller, set outlet to that view.
#property(nonatomic,strong)IBOutlet UIView *viewTop;
Setp 2)
Add following single line code on viewDidLoad
[self.tableview setTableHeaderView:self.viewTop];

Resources