我正在运行我的应用程序时收到此帖子。
2012-07-10 15:44:39.668 DSSAmple[447:f803] -[cell superview]: unrecognized selector sent to instance 0x68b4080
2012-07-10 15:44:39.671 DSSAmple[447:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[cell superview]: unrecognized selector sent to instance 0x68b4080'
'cell'被称为我的子类。
在cell.h中我有
@interface cell : UIViewController
{
UIImage *MyImage;
int row;
int column;
CGRect frame;
}
@property(retain,nonatomic)UIImage *MyImage;
@property(assign,nonatomic)int row;
@property(assign,nonatomic)CGRect frame;
@property(assign,nonatomic)int column;
@end
在我的通话课中,我有 SIAViewcontroller.h
#import <UIKit/UIKit.h>
#import "cell.h"
@interface SIAViewController : UIViewController
-(void)PanelLoading;
@end
在其实施中 SIAViewController.m
-(void)PanelLoading
{
UIImage *myImage=[UIImage imageNamed:@"s.jpg"];
int x=20,y=50,r=1,c=1;
for (int i=1; i<=8; i++)
{
for (int j=1; j<=8; j++)
{
cell *tank=[[cell alloc]init];
tank.column=c;
tank.row=r;
tank.frame=CGRectMake(x, y, 35, 35);
tank.MyImage=myImage;
[self.view addSubview:tank];
x+=35;
r++;
}
r=1;
c++;
y+=35;
x=20;
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self PanelLoading];
// Do any additional setup after loading the view, typically from a nib.
}
这是什么原因?有人可以帮忙吗?
答案 0 :(得分:2)
您的cell
课程应该延伸UIView
而不是UIViewController
。
@interface cell : UIView
UIView
提供superview
属性,而UIViewController
则不会,触发“无法识别的选择器”崩溃。