Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1020865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:13:23+00:00 2026-05-16T11:13:23+00:00

I am facing an issue while implementing MVC. I created a UIView subclass and

  • 0

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];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:13:23+00:00Added an answer on May 16, 2026 at 11:13 am

    I got the issue… Actually, i was not allocating memory to my UIView subclass components and was trying to use drawAtPoint method. Once i allocated memory to and added them as a subview of my view class, i got the correct screen displayed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have implemented webservice which generates xml response. I am facing issue while invoking
I am facing an issue while loading a UIWebView .I have a webview(1st) where
I am new to ASP.Net MVC 3, facing some issues while trying to implementing
Here I am facing an issue in hibernate criteria usage, I have created criteria
facing the issue while debugging String.hashCode() line: not available i have refereed this ,
I am facing an issue while loading the Page created using Razor Template using
I am facing issue while i load a form on ajax request. i followed
i am using Codeigniter i am facing an issue while setting the values of
issue facing while loading the messages in to mq channel, recieving an error like
I am facing the following issue while uploading the video from my android application.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.