androniennn
androniennn

Reputation: 3137

Can't add a UIView above UITableView from storyboard

I'm trying to add a UIView above UITableView, replacing the navigation bar: enter image description here

And this is how the controller is structured: enter image description here

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.

Upvotes: 0

Views: 859

Answers (2)

Mahesh Pawar
Mahesh Pawar

Reputation: 57

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];

Upvotes: 0

Tommy Devoy
Tommy Devoy

Reputation: 13549

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!

Upvotes: 1

Related Questions