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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:56:47+00:00 2026-06-02T04:56:47+00:00

I am an absolute newbie at ios programming so forgive me: I have a

  • 0

I am an absolute newbie at ios programming so forgive me:

I have a subclass of UIView called PuzzlePiece that I want to represent just a single puzzle piece (obviously). I don’t want to use a nib file for it, but just want to be able to draw a piece using code and display it.

I have a view controller and associated nib file that will hold the entire puzzle. The view in the nib is of type PuzzleView which is another class that I have defined as a custom subclass of UIView. My PuzzleView works fine and I can draw on it and everything. I have a property of type PuzzlePiece called piece that I figured can refer to my puzzle piece.

So all I am trying to figure out how to do is to now initialize my view, add it as a subview, and draw it on the screen. Sounds simple, but I am at a complete loss of how to make this work. I would totally believe that I am not even approaching the problem correctly, so if that is the case, please advise me!

I thought I should be able to do something like

piece = [[puzzlePiece alloc] initWithFrame: ... ];
[self addSubview:piece];

But… the init bit doesn’t work… and really no init methods seem to be available to me.

So… yeah. How do I just add a custom subclass of uiview as a subview to another custom subclass of uiview in code?

  • 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-02T04:56:49+00:00Added an answer on June 2, 2026 at 4:56 am

    Do you need to capitalize puzzlePiece?

    PuzzlePiece *piece = [[PuzzlePiece alloc] initWithFrame:CGRect(0, 0, 100, 100)];
    

    If PuzzlePiece derives from UIView then your code looks like it should work.

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

Sidebar

Related Questions

Absolute beginner question: I have a template file index.html that looks like this: ...
I'm an absolute newbie to Moose and so far I have read Moose and
Although experienced with OOP, I am an absolute newbie with Objective-C. I have the
I am an absolute newbie without even a computer science background. I am just
Currently we're evaluating NuGet so I'm an absolute newbie to the subject. Just to
Forgive me if this is a newbie question - but sadly that's what I
Absolute newbie question, any help is highly appreciated :) I am using curvycorners (
I am an absolute newbie in Haskell yet trying to understand how it works.
I am an absolute objective-c, c, and openGL newbie. Hence, when I found coco2d
Disclaimer: absolute novice in Scala :( I have the following defined: def tryAndReport(body: Unit)

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.