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

  • Home
  • SEARCH
  • 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 7161587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:35:30+00:00 2026-05-28T13:35:30+00:00

I have experience on windows client dev, language c++, and Flash ActionScript3 dev, but

  • 0

I have experience on windows client dev, language c++, and Flash ActionScript3 dev, but i’m quite a beginner on iOS dev…

to make it really detailed this post may be a little too long…

my Xcode ver is 4.2.1

i created an iOS Application(Empty Application), and there are only (MyAppDelegate.h) and (MyAppDelegate.m), if i compile and run it, there will be a white board displayed, and nothing more, that we all know.

now, i want to draw a picture, or a simple rect or whatever something on the screen, and i don’t want to use storyboard, so i create a new Objective-C class: MyView, which inherit from UIView. and override the function – (void)drawRect:(CGRect)rect

then i write something like this in MyAppDelegate.m’s didFinishLaunchingWithOptions function:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    self.window.rootViewController.view = [[MyView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.window.rootViewController.view drawRect:[[UIScreen mainScreen] bounds]];
    return YES;
}

so you see, what i do is alloc a new MyView instance and assign it to self.window.rootViewController.view, and then invoke drawRect function.
but when i put a breakpoint in MyView’s drawRect func and debug, it didn’t stop there, that means the app never went there, i really can’t figure out why.

i read Docs about View and ViewController but they did’t tell this problem , hope you can help me! and please tell me what should i read to know more about this topic

  • 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-28T13:35:31+00:00Added an answer on May 28, 2026 at 1:35 pm

    First off NEVER call drawRect directly, the system calls this. Secondly in your example you have no view controller so in fact rootViewController is nil, hence why nothing is working.

    You should either create a view controller to manage your view OR simply add your UIView subclass to the window directly…

    [self.window addSubview:myView];
    

    NOTE: You should be using a UIViewController to manage this for you however!

    If you are new to objective-c then I would start with a UIView project rather than an empty one, and take a look how everything hangs together.

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

Sidebar

Related Questions

I have no experience developing C++ on Windows, but I am a C# developer.
I'm technically savvy but don't have extensive experience with servers/daemons (I'm a Windows guy,
I have experience in client-server application development in C/C++ on Windows platform. I would
Does anyone have any experience hosting the Windows Workflow designer surface? I've seen a
Does anyone have experience writing professional OpenGL games on Windows? For the Mac, due
Does anybody have any experience/ knowledge in installing the aspImage.dll on a 64-bit Windows
I have very little experience building software for Windows, and zero experience using the
I have some experience with programming, but I have very little experience when it
I don't have experience in using ms-access as client-server in window application. Let me
I have experience in GWT but know nothing about JSNI or Javascript . i

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.