I am getting this thread while running my app.
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' is called my subclass.
In cell.h i have
@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
And in my calling class i have SIAViewcontroller.h
#import <UIKit/UIKit.h>
#import "cell.h"
@interface SIAViewController : UIViewController
-(void)PanelLoading;
@end
In its implementation 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.
}
What Would be the reason for this? Can anybody help?
Your cell class should extend UIView rather than UIViewController.
@interface cell : UIView
UIView provides a superview property, while UIViewController does not, triggering the "unrecognized selector" crash.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With