3

我在运行我的应用程序时收到了这个线程。

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.hi 中有

@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.
}

这会是什么原因?有人可以帮忙吗?

4

1 回答 1

2

你的cell类应该扩展UIView而不是UIViewController.

@interface cell : UIView

UIView提供一个superview属性,而UIViewController没有,触发“无法识别的选择器”崩溃。

于 2012-07-10T11:07:43.523 回答