Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS:自定义UITableViewCell的实现需要调用超级_Ios_Objective C_Cocoa Touch_Uitableview - Fatal编程技术网

iOS:自定义UITableViewCell的实现需要调用超级

iOS:自定义UITableViewCell的实现需要调用超级,ios,objective-c,cocoa-touch,uitableview,Ios,Objective C,Cocoa Touch,Uitableview,“*在-[PlayingCell layoutSublayersOfLayer:]中断言失败, /SourceCache/UIKit_Sim/UIKit-2372/UIView.m:5776 2013-11-01 18:44:12.526快照[216:c07]*由于未捕获而终止应用程序 异常“NSInternalInconsistencyException”,原因:“自动布局” 执行后仍然需要-layoutSubviews.PlayingCell的 -布局子视图的实现需要调用super。“” 我

*在-[PlayingCell layoutSublayersOfLayer:]中断言失败, /SourceCache/UIKit_Sim/UIKit-2372/UIView.m:5776 2013-11-01 18:44:12.526快照[216:c07]*由于未捕获而终止应用程序 异常“NSInternalInconsistencyException”,原因:“自动布局” 执行后仍然需要-layoutSubviews.PlayingCell的 -布局子视图的实现需要调用super。“”

我正在尝试在iOS6模拟器中运行我的应用程序(我为iOS7设计的)。我的项目包含一个TabBarController。在tabbarcontroller的第一个视图控制器中,我有一个包含自定义UITableViewCell的表视图。他们装载没有问题。然而,当我切换到另一个选项卡时,在那里我有另一个表视图,也有自定义单元格,我得到上面公布的错误。ViewController的设置几乎相同(都具有使用自动布局组织的子视图)。有没有人见过这个例外/知道如何解决它

谢谢

编辑:播放单元格的代码。

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

}
#导入
@界面播放单元:UITableViewCell
@属性(强,非原子)ibuilabel*lblTrackNum;
@属性(强,非原子)IBUIImageView*albumArt;
@属性(强,非原子)IBUILabel*lblSongTitle;
@属性(强,非原子)IBUILabel*lblAlbumTitle;
@性质(强,非原子)IBUILabel*lblArtist;
@属性(强,非原子)IBUIImageView*imgPlay;
@属性(强,非原子)NSMutableDictionary*songInfo;
-(iAction)downloadBtnPressed:(id)发件人;
@结束
#导入“PlayingCell.h”
@PlayingCell的实现
@合成歌曲信息;
-(id)initWithStyle:(UITableViewCellStyle)样式重用标识符:(NSString*)重用标识符
{
self=[super-initWithStyle:style-reuseIdentifier:reuseIdentifier];
如果(自我){
//初始化代码
}
回归自我;
}
-(无效)设置选定:(BOOL)选定动画:(BOOL)动画
{
[超级设置选定:选定动画:动画];
//为所选状态配置视图
}
-(iAction)下载B已按下:(id)发件人
{
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:[songInfo objectForKey:@“trackViewUrl”]];
NSLog(@“%@,[songInfo objectForKey:@“trackViewUrl]”);
}
-(无效)布局子视图
{
[超级布局子视图];
}

执行错误说明的操作。在一个自定义单元格类中,您似乎正在覆盖
layoutSubviews
方法。您必须在实现中调用
[super layoutSubviews]
。这通常是第1行

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

执行错误说明的操作。在一个自定义单元格类中,您似乎正在覆盖
layoutSubviews
方法。您必须在实现中调用
[super layoutSubviews]
。这通常是第1行

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

我为我的自定义单元格添加了代码。我添加了该代码,但仍然出现错误。我添加了自定义单元格的代码。我添加了该代码,但仍然出现错误。是否确实在添加自定义表格单元格时拖动了UITableViewCell而不是UIView?UIView也可以添加到表格视图中。这只会在自动布局启用时导致问题。啊,我发现了错误。我使用PlayingCell作为表视图标题的nib的基本结构(因为它有一个用于图像的IBOutlet,我懒得创建一个新的子类),这太愚蠢了。无论如何,它似乎适用于iOS 7,但使用UITableViewCell作为标题视图的自定义视图并不是一个好主意。我要关闭这个,其他人不应该碰到这个问题!是否确实在添加自定义表格单元格时拖动的是UITableViewCell而不是UIView?UIView也可以添加到表格视图中。这只会在自动布局启用时导致问题。啊,我发现了错误。我使用PlayingCell作为表视图标题的nib的基本结构(因为它有一个用于图像的IBOutlet,我懒得创建一个新的子类),这太愚蠢了。无论如何,它似乎适用于iOS 7,但使用UITableViewCell作为标题视图的自定义视图并不是一个好主意。我要关闭这个,其他人不应该碰到这个问题!