“ *断言失败 - [PlayingCell layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2372/UIView.m:5776 2013-11-01 18:44:12.526 SnapTrack [216:c07] * 由于未被捕获而终止应用程序 异常'NSInternalInconsistencyException',原因:'自动布局 执行-layoutSubviews后仍然需要。 PlayingCell的 -layoutSubviews的实现需要调用super。'“
我正在尝试在iOS6模拟器中运行我的应用程序(我为iOS7设计)。我的项目包含一个TabBarController。在tabbarcontroller的第一个视图控制器中,我有一个包含自定义UITableViewCell的表视图。他们加载没有问题。但是,当我切换到另一个选项卡,我有另一个表视图,也有自定义单元格时,我收到上面发布的错误。 viewControllers几乎完全相同(都有使用自动布局组织的子视图)。有没有人见过这个例外/知道如何解决它?
谢谢!
编辑:PlayCell的代码。
#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];
}
答案 0 :(得分:1)
执行错误说明的内容。在您的一个自定义单元格类中,您似乎覆盖了layoutSubviews
方法。您必须在实施中致电[super layoutSubviews]
。这通常是第一行。
- (void)layoutSubviews {
[super layoutSubviews];
// the rest of your custom layout code
}