1
votes

"* Assertion failure in -[PlayingCell layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2372/UIView.m:5776 2013-11-01 18:44:12.526 SnapTrack[216:c07] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. PlayingCell's implementation of -layoutSubviews needs to call super.'"

I'm trying to run my app (which I designed for iOS7) in the iOS6 simulator. My project contains a TabBarController. In the first view controller in the tabbarcontroller I have a table view containing custom UITableViewCell's. They load without a problem. However, when I switch to another tab, where I have another table view, also with custom cells, I get the error posted above. The viewControllers are set up almost identically (both have subviews organized with auto layout). Has anyone seen this exception/know how to address it?

Thanks!

EDIT: Code for PlayingCell.

#import <UIKit/UIKit.h>

@interface PlayingCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UILabel *lblTrackNum;
@property (strong, nonatomic) IBOutlet UIImageView *albumArt;
@property (strong, nonatomic) IBOutlet UILabel *lblSongTitle;

@property (strong, nonatomic) IBOutlet UILabel *lblAlbumTitle;
@property (strong, nonatomic) IBOutlet UILabel *lblArtist;

@property (strong, nonatomic) IBOutlet UIImageView *imgPlay;
@property (strong,nonatomic) NSMutableDictionary *songInfo;

- (IBAction)downloadBtnPressed:(id)sender;

@end
#import "PlayingCell.h"

@implementation PlayingCell
@synthesize songInfo;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (IBAction)downloadBtnPressed:(id)sender

{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[songInfo objectForKey:@"trackViewUrl"]]];
    NSLog(@"%@",[songInfo objectForKey:@"trackViewUrl"]);
}

-(void)layoutSubviews
{
    [super layoutSubviews];

}
1
Are you sure that when you added your custom table cell you dragged a UITableViewCell and not UIView?hasan
UIView can also be added to table view. it's only causing a problem when auto layout enabled.hasan
Ah I found the error. It was stupid I was using a PlayingCell as the base structure (because it had an IBOutlet for an image and I was too lazy to make a new subclass) for a nib for the header of the table view. Anyway, it seemed to work for iOS 7 but using a UITableViewCell as a custom view for a header view wasn't a great idea anyway. I'm going to close this, no one else should run into this problem!JoshDG

1 Answers

1
votes

Do what the error states. In one of your custom cell classes you appear to be overriding the layoutSubviews method. You must call [super layoutSubviews] in your implementation. This is typically the 1st line.

- (void)layoutSubviews {
    [super layoutSubviews];
    // the rest of your custom layout code
}