Hi, I am facing an issue while implementing MVC. I created a UIView subclass and have designed my custom view. I created a UIViewController subclass and pointed its view to my custom view class. Finally I created a NSObject subclass and created a model for my controller. When i am running the app, i am getting a black screen... Any idea on this?
==My Model==
-(id) init { imgArray = [[NSMutableArray alloc] initWithObjects: [UIImage imageNamed:@"scene.jpg"], [UIImage imageNamed:@"scene1.jpg"], [UIImage imageNamed:@"scene2.jpg"], nil];
return self;
}
============
==My Controller==
(void)viewDidLoad { [super viewDidLoad]; NSNotification CGRect mainFrame = [[UIScreen mainScreen] applicationFrame];
// Get the view MVCView *myView = [[MVCView alloc] initWithFrame:mainFrame];
// Get the data MVCModel *myModel = [[MVCModel alloc] init]; myView.myImgView.image = [myModel.imgArray objectAtIndex:0];
//[self.view addSubview:myView]; [myView setNeedsDisplay]; self.view = myView; self.title = @"MVC"; }
============
**==My View== - (id)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { // Initialization code CGRect imgFrame = CGRectMake(5, 20, 150, 150); //myImgView.image = [UIImage imageNamed:@"scene.jpg"]; myImgView.frame = imgFrame;
CGRect lblFrame = CGRectMake(5, 150, 50, 50);
myLabel.text = @"Nature is beautiful";
myLabel.frame = lblFrame;
CGRect sldFrame = CGRectMake(5, 200, 50, 50);
mySlider.minimumValue = 0;
mySlider.maximumValue = 100;
mySlider.frame = sldFrame;
}
return self;
}
// Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code
CGPoint imgPoint = CGPointMake(10, 20);
[self.myImgView drawAtPoint:imgPoint];
CGPoint lblPoint = CGPointMake(10, 160);
[self.myLabel drawAtPoint:lblPoint];
CGPoint sldPoint = CGPointMake(10, 210);
[self.mySlider drawAtPoint:sldPoint];
} ============**