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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:36:00+00:00 2026-05-15T05:36:00+00:00

I need to create my own UIView class and it is not something I

  • 0

I need to create my own UIView class and it is not something I have had to do. I created the class, then laid out the small view in IB (it’s just a few labels that i will later need to add data to ). but now im stuck on how to actually put an instance of it in my main view. Can someone point me in the direction of a good tutorial? The closest thing I have done to this is creating a custom tableViewCell.

DataTagViewController.m:

- (id)initWithNibNamed:(NSString *)DataTagViewController    bundle:bundle {
    if ((self = [super initWithNibName:DataTagViewController bundle: bundle])) {
        // Custom initialization
    }
    return self;
}


MapView.m:

    DataTagViewController *dataTag = [[DataTagViewController alloc] initWithNibNamed:@"DataTagViewController" bundle:nil];

    [theMap addSubView: dataTag.view]; <<< this line causes the crash (theMap is a UIView)

I now get this runtime error when adding the subview:-[UIView addSubView:]: unrecognized selector sent to instance 0x470f070′
2010-06-06 21:22:08.931

  • 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-15T05:36:01+00:00Added an answer on May 15, 2026 at 5:36 am

    UIViewController is not a view, but controls a view. If your DataTagViewController class extends UIViewController, then you’ll want to add it’s view, not the class itself:

    [theMap addSubView:dataTag.view];
    

    Also, do you have a DataTagViewController.xib file created that has your view in it? If you don’t, you’ll need to create one and use the UIViewController‘s initWithNibName:bundle method. Otherwise, you’ll have to implement the loadView method instead to provide your own view via code.

    Edit

    Your init function is using the name of your class as a variable. That probably won’t work. Use the default sigature:

    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
        {
        }
    } 
    

    If you aren’t doing anything beyond the init function, you don’t need to implement this method. Your alloc/init statement is enough.

    For a good tutorial, read the View Controller Programming guide in the docs.

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

Sidebar

Related Questions

Suppose I need to create my own small DSL that would use Python to
I need to create my own class that extends Hash and append the additional
I need to create my own coordinate system in UIView, where 0,0 is center
I need to create my own grid which will have customized paging and sorting.
I have some problem to implement twig extension. I need to create my own
I need to create my own view with controller on empty template without help
Do I need to create my own InvalidArgumentException.. I couldn't find any built-in types
i am using raw sockets to create my own socket. i need to set
I need to create an XML schema that looks something like this: <xs:element name=wrapperElement>
I need to create an ASP page (classic, not ASP.NET) which runs remote shell

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.