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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:37:15+00:00 2026-06-04T16:37:15+00:00

i try to add a UIView to my application. it does work but not

  • 0

i try to add a UIView to my application. it does work but not as expected. i´ve defined the socialActionView in my header and made a @synthesize in my view controller.

the nib-file is loaded when the user tabs a button. i thought i have to call the addSubview-method to show the view. but it shows up even i i don´t do it.

if i call the addSubView-method anyway the app crashes when i load the view with the message “warning: Unable to restore previously selected frame.”

can anybody explain what´s goning on here? i don´t understand that.

- (IBAction)didTapOkSocialAction:(id)sender;
{
    self.socialActionView = [[[NSBundle mainBundle] loadNibNamed:@"SocialActionViewController" owner:self options:nil] objectAtIndex:0];
    //[self.view addSubview:socialActionView];
}

EDIT

in this case the solution was to set the file´s owner of my SocialActionViewController.xib to ViewController.h. i don´t know yet how to add a UIView from NIB attached to another view controller class than the view controller where the view is loaded into.

  • 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-04T16:37:16+00:00Added an answer on June 4, 2026 at 4:37 pm

    Your socialActionView is already bound to the view placeholder in its superview.

    So: its already there (its reference is already added as a subview) but it is nil until you actually load it.

    EDIT: it’s not clear how you have everything connected there, but from your added info below i’ll take a wild guess.

    Try this code:

    - (IBAction)didTapOkSocialAction:(id)sender;
    {
        UIView *loadedView = [[[NSBundle mainBundle] loadNibNamed:@"SocialActionViewController" owner:self options:nil] objectAtIndex:0];
    
        [self.view addSubview:loadedView];
    }
    

    EDIT: since you want to programatically load a viewcontroller from .xib you can do it like so (supposably viewcontroller is defined in MyViewController.h,.m,.xib):

    MyViewController *myViewController;  //as an ivar or a property in @interface
    
    
    myViewController = [[ViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
    

    then you can add it’s view:

    [self.view addSubview: myViewController.view];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to add a function in a PyQt class, but it always returns
I try to add a subview(which is a subclassed UIViewController's view, consists of several
I have done an layout in my GUI but it did not work ,
I try add and compile ffmpeg library in my own android application. When I
I try to remove a view from it's superview after being animated offscreen. But
I try to add a text filed and a button to the grid panel
I try to add IP Extraction filter in google analytics for show visitor ip!
I try to add dots between the page title and the page number in
I try to add Message.framework to my project frameworks directory. After that I compile
I try to add a class to a td-element using javascript with the internet

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.