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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:29:12+00:00 2026-05-24T05:29:12+00:00

I’ve loaded a UIView (FirstView.m) with a separate XIB (SecondView.xib), but the buttons in

  • 0

I’ve loaded a UIView (FirstView.m) with a separate XIB (SecondView.xib), but the buttons in that XIB crash the app. The code for the buttons (IBOutlet & IBAction) are in SecondView.m.

Do I need to point the code from SecondView.m to FirstView.m? I tried using #import and @class… but was unsuccessful.

The code I’m using is completely valid… I’m pretty sure the issue has something to do with the XIB being loaded into the UIView… and then possibly losing its connection to the implementation file. Thoughts?

Thanks in advance!

FirstView.h

#import <UIKit/UIKit.h>
@interface FirstView : UIViewController {
    IBOutlet UIView *SecondViewPopUP;
    IBOutlet UIButton *openBTN;
    }

@property (nonatomic, retain) UIView *SecondViewPopUP;
@property (nonatomic, retain) IBOutlet UIButton *openBTN;
-(IBAction)showPopUp:(id)sender;

FirstView.m

@synthesize SecondViewPopUP;
@synthesize openBTN

- (void)viewDidLoad {
    SecondViewPopUP.alpha = 0;

    // Add IncidentsViewController to view
    SecondView *SecondV=[[SecondView alloc] init];
    SecondV.view.frame = CGRectMake(0, 0, 262, 269);
    SecondV.view.clipsToBounds = YES;
    [SecondViewPopUP addSubview:SecondV.view];
    SecondViewPopUP.frame = CGRectMake(0, 76, 262, 269);
    [SecondV release];
    }

-(IBAction)showPopUp:(id)sender {
    NSLog(@"Stats Button was pressed");

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.4];

    SecondViewPopUP.alpha = 1;

    [UIView commitAnimations];
    }

SecondView.h

#import <UIKit/UIKit.h>

@interface ShareViewController : UIViewController {
    IBOutlet UIButton *share_facebook;
    IBOutlet UIButton *share_twitter;
    }

@property (nonatomic, retain) IBOutlet UIButton *share_facebook;
@property (nonatomic, retain) IBOutlet UIButton *share_twitter;

-(IBAction)shareOnFB:(id)sender;
-(IBAction)shareOnTwitter:(id)sender;

SecondView.m

@synthesize share_twitter, share_facebook;
- (void)viewDidLoad {
    [super viewDidLoad];
    }

-(IBAction)shareOnFB:(id)sender {
    NSLog(@"Shared on FB");
    }

-(IBAction)shareOnTwitter:(id)sender {
    NSLog(@"Shared on Twitter");    
    }
  • 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-24T05:29:13+00:00Added an answer on May 24, 2026 at 5:29 am

    First of all FirstView (and presumably SecondView) is a UIViewController not a UIView so naming it “FirstViewController” would be much clearer. Views and view controllers are very different things.

    Secondly you are adding a UIViewController’s view as a subview of another view on the line “[SecondViewPopUP addSubview:SecondV.view];” That’s not how UIViewControllers are expected to be used and the UIViewController programming guide recommends against it for good reason.

    Each custom view controller object you create is responsible for managing all of the views in a single view hierarchy. In iPhone applications, the views in a view hierarchy traditionally cover the entire screen, but in iPad applications they may cover only a portion of the screen. The one-to-one correspondence between a view controller and the views in its view hierarchy is the key design consideration. You should not use multiple custom view controllers to manage different portions of the same view hierarchy. Similarly, you should not use a single custom view controller object to manage multiple screens worth of content.

    Finally if you were to post the error listed when your app crashes we would probably see that you are attempting to send -shareOnFB: or -shareOnTwitter: messages to an instance of “FirstView” which does not implement them because your nib bindings are not configured appropriately ie you set the File’s Owner of the nib to be “SecondView” and then loaded it with an instance of “FirstView” as its owner. Impossible to say for sure without more data.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping 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.