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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:08:59+00:00 2026-05-22T13:08:59+00:00

I have a xib-file with a small UIView on it, which in turn contains

  • 0

I have a xib-file with a small UIView on it, which in turn contains some labels. Now, I’m trying to load that UIView into an existing UIViewController, and change one of the label-texts. The reason I want to do it this way, is that the UIView will be reused with different label-texts so I figured making a custom class and loading it from a xib would be the best way to go.

I have tried several ways of loading it and I’ve successfully displayed it on my viewcontroller. The problem is, once I try to actually link an IBOutlet in Interface Builder, and access it, my app crashes.

I have created a custom UIView class, which looks like this:

CoverPanel.h

@interface CoverPanel : UIView {

    IBOutlet UILabel *headline;

}

@property (nonatomic, retain) IBOutlet UILabel *headline;

@end

CoverPanel.m

@implementation CoverPanel

@synthesize headline;

- (id)initWithFrame:(CGRect)frame 
{
    self = [super initWithFrame:frame];
    if (self) 
    {
        // Initialization code.
        //
        self = [[[NSBundle mainBundle] loadNibNamed:@"CoverPanel" owner:self options:nil] objectAtIndex:0];
    }
    return self;
}

In the CoverPanel.xib, I have linked the UILabel to the headline outlet.
In my viewcontroller, here’s how I create the CoverPanel instance, and this is where it crashes:

CoverPanel *panelView = [[CoverPanel alloc] initWithFrame:CGRectMake(0,0,300,100)];

So far, so good. It displays the UIView exactly as it’s layed out in the .xib.
But as soon as I try to change the headline.text like so:

panelView.headline.text = @"Test";

it crashes with this error:
Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[UIView headline]: unrecognized selector sent to instance 0x5c22b00’

It might be something tiny I’m overlooking, but it has been driving me insane for hours and hours so far. Does anyone have any idea?

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

    You reassigned your custom view’s class to the view that lived in your xib. You don’t need to do that because then what you got back was the view from the xib and you’ve just leaked your CoverPanel. So, simply replace your initializer:

    - (id)initWithFrame:(CGRect)frame 
    {
        self = [super initWithFrame:frame];
        if (self) 
        {
            // No need to re-assign self here... owner:self is all you need to get
            // your outlet wired up...
            UIView* xibView = [[[NSBundle mainBundle] loadNibNamed:@"CoverPanel" owner:self options:nil] objectAtIndex:0];
            // now add the view to ourselves...
            [xibView setFrame:[self bounds]];
            [self addSubview:xibView]; // we automatically retain this with -addSubview:
        }
        return self;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

everyone. I have some labels that I draw them in the xib file, and
In my xib file I have some View. And I have PainView class (UIView).
I have 3 file: MyViewController.h MyViewController.m MyViewController.xib MyViewController.xib have some view which i removed?
I have custom UIView that has a xib file as well as .h and
I have a XIB file with a UITextView, which I'm associating with a UITextView*
I have an xib file includes a UIView and a UIScrollView. Inside my UIView,
i have two .xib file like a.xib and b.xib. Now i am in b.xib
I have several ViewControllers which subclass UITableViewController and have a Xib file where I
I have a UIView control in the nib file that I am working on.
I have a xib file with some UILabels. In - (void)viewDidLoad I send a

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.