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 7834081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:03:19+00:00 2026-06-02T13:03:19+00:00

Using XCode 4.3.2, if a new class TestView is added (with TestView.h and .m

  • 0

Using XCode 4.3.2, if a new class TestView is added (with TestView.h and .m added), and it is a subclass of UIView, and it is drawing things inside the drawRect method. Why does the file ViewController.xib has be clicked on, and the Identity Inspector has to be clicked on, and the Custom Class has to be changed from UIView to TestView?

What does doing so mean? What if that is not changed — can the code in drawRect in TestView.m still be easily invoked? Alternatively, can all the code in TestView.m be moved to ViewController.m? If so, how can that be done, as TestView inherits from UIView, but ViewController inherits from UIViewController and ViewController‘s drawRect may not get called.

  • 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-06-02T13:03:20+00:00Added an answer on June 2, 2026 at 1:03 pm

    The common way to do custom drawing is to implement a UIView subclass and implement drawRect. The only way to make that drawing visible is to add the custom view to a view hierarchy which is controlled by – but not drawn by – a view controller.

    The xib describes the user interface. Adding a UIView subclass (like TestView) in the xib causes an instance of that class to be allocated an attached to the view hierarchy. The class name is required to know which class to instantiate (make an instance of).

    drawRect is a UIView method that is called by the system when it decides that some or all of the view needs to be drawn. Applications do not call it directly. They implement it and let the system call it.

    ViewControllers don’t draw anything, they only manage the hierarchy of views. So there’s no point in implementing drawRect in a view controller.

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

Sidebar

Related Questions

I have added a category to my Xcode project using File > New >
I just created a new Xcode project. In the AppControl class Header file I
I am Abbas,I am new to iPhone Development, Till tomorrow i am using xcode
I'm using the new Storyboarding feature in Xcode 4.2, and I've run into a
I am developing a storyboard-based application, using XCode 4.2. I'm new to storyboards, before
I was using Xcode 4.1 and after upgrading to 4.2, things started to become
I created a new project in Xcode 4 using the Cocoa Application template and
Using Xcode 4.2.1 iPad iOS 5.0.1, create a new Single View iPad project. In
Background: Up until Xcode 4.2, new projects created using any of the templates would
I am new to iphone development. I am using xCode 4.2 with storyboard. 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.