The problem with segue-transition in the Storyboard?

Have a UITableViewController with UISearchDisplayController which displays a list of some items. In order to in the main table and the lookup table the information was presented in the same was created GoodsCell cell (inherit from UITableViewCell). GoodsCell created programmatically and has the following simple form:

@interface GoodsCell ()
 UIImageView *photoView;
 UILabel *titleLabel;


@implementation GoodsCell

- (GoodsCell *)init {
 CGRect frame = CGRectMake(0.0 f, 0.0 f, 320.0 f, 70.0 f);

 self = [super initWithFrame:frame];
 if (self) {
 photoView = [[UIImageView alloc] initWithFrame:CGRectMake(10.0 f, 10.0 f, 50.0 f, 50.0 f)];
 [self addSubview:photoView];

 self.accessoryType = UITableViewCellAccessoryDisclosureindicator;

 titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(70.0 f, 10.0 f, 215.0 f, 50.0 f)];
 // set some attributes for the label
 [self addSubview:titleLabel];

 return self;

- (void)setPhoto:(UIImage *)photo {
 photoView.image = photo;

- (void)setTitle:(NSString *)title {
 [titleLabel setText:title];


In a Storyboard-e created a Seque from directly GoodsViewController (responsible for displaying the list of items) to GoodsDetailViewController (detailed product information). The treatment of depression is as follows:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
 [self performSegueWithIdentifier:@"goodsDetail" sender:tableView];

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
 if ([[segue identifier] isEqualToString:@"goodsDetail"])
 GoodsDetailViewController *goodsDetailViewController = (GoodsDetailViewController *)[segue destinationViewController];

 if (sender == self.searchDisplayController.searchResultsTableView)
 NSIndexPath *indexPath = [self.searchDisplayController.searchResultsTableView indexPathForSelectedRow];
 Goods *goods = [foundGoodsObjects objectAtIndex:indexPath.row];
 [goodsDetailViewController setGoods:goods];
 NSIndexPath *indexPath = [goodsTable indexPathForSelectedRow];
 Goods *goods = [goodsObjects objectAtIndex:indexPath.row];
 [goodsDetailViewController setGoods:goods];

When you click on a cell the app crashes with the error:

*** Assertion failure in -[GoodsCell layoutSublayersOfLayer:], /SourceCache/UIKit/UIKit-2372/UIView.m:5776
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing-layoutSubviews. GoodsCell''s implementation of-layoutSubviews needs to call super.'

The code in the current version of the project has been migrated from another git branch, if not a very good conflict merge. The elements in the Storyboard and IBOutlet-s were added manually. In the original thread everything works fine — switch to detailed view occurs, do not fall.

Racked my brains, what's the problem. Need help, dear charasmatic!

P. S. Tried to place a fake cell in the table and do a seque from it — fails, the result is the same.
October 3rd 19 at 03:51
7 answers
October 3rd 19 at 03:53
You can look at this topic hereand here
October 3rd 19 at 03:55
So the error also indicates what he wants: GoodsCell''s implementation of-layoutSubviews needs to call super.
According to this jamb is not in the above code, and where the TableView GoodCell their fill — they have to kick the parent
October 3rd 19 at 03:57
in my opinion it is not good for init to call initWithFrame, overload already from initWithFrame. sets the height of the cell here will do nothing, it will still be managed by the table in heightForRowAtIndexPath:
October 3rd 19 at 03:59
Segue you can pull directly from the cells, then there is no need to implement such didSelectRowForIndexPath
October 3rd 19 at 04:01
Wow! How do you create the cell? [[GoodsCell alloc] init]?
Even Google hints at [theContainerView setTranslatesAutoresizingMaskIntoconstraints:NO]; — kind of helps people. - Jimmie.Wiegand commented on October 3rd 19 at 04:04
October 3rd 19 at 04:03
If you are using an NSLayoutConstraint to set the titleLabel in the cell, it is necessary to specify the titleLabel.translatesAutoresizingMaskIntoConstraints = NO.
All UIView that rasstavlyaet using NSLayoutConstraint (AutoLayout is), it is necessary to specify view.translatesAutoresizingMaskIntoConstraints = NO.
And if you use AutoLayout using InterfaceBuilder, it automatically changes this flag.
October 3rd 19 at 04:05
carefully did not penetrate, but to overload the init, and even with a call to initWithFrame - not a good idea
not exactly sure, but I think if you overload the grid, we
- initWithStyle:reuseIdentifier:
in your viewController, the table should do
- registerClass:forCellReuseIdentifier:
and then as usual use
- dequeueReusableCellWithIdentifier:

or even make a xib for the cell, there to put everything, to make some constraints and use
UITableView registerNib:forCellReuseIdentifier:
here zhezh, it turns out I already answered this topic.. :) - Jimmie.Wiegand commented on October 3rd 19 at 04:08

Find more questions by tags iOSApple XcodeCocoaObjective-C