I have some kind of strange error and I can not find a solution.
I have a UITableView using auto layout. (Binding to the parent object from all sides). If I rotate the device, it will display correctly, but if I try to scroll it, scroll it to the left of the screen.

The red square is the scroll area.
The next problem that I assume is related to this when I try to add a UIView as a subView in a UITableView.
if i add:
CGRect frame = CGRectMake(0, 200, self.table.frame.size.width, 5);
UIView * mainView = [[UIView alloc]initWithFrame:frame];
mainView.backgroundColor = [UIColor redColor];
[self.table addSubview:mainView];
ok but if i like:
UIView * mainView = [[UIView alloc]init];
mainView.backgroundColor = [UIColor redColor];
mainView.translatesAutoresizingMaskIntoConstraints = NO;
[self.table addSubview:mainView];
[self.table addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(200)-[mainView(20)]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(_table, mainView)]];
[self.table addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[mainView]|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(_table, mainView)]];
get na error:
*** Assertion failure in -[UITableView layoutSublayersOfLayer:], /SourceCache/UIKit/UIKit-2903.23/UIView.m:8540
source
share