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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:49:31+00:00 2026-06-15T14:49:31+00:00

So, I want to create a reusable widget as a xib and subview that

  • 0

So, I want to create a reusable widget as a xib and subview that can appear on a set amount of specific screens. This widget will have three buttons, each with an Action.

I want to be able to handle these actions on multiple viewcontrollers.

So say ViewControllerA, ViewControllerD, and ViewControllerF can handle the three button events, each in their own way.

I’ve created the nib file. How do I import it into the specific viewcontrollers, and then how do I wire up those events?

EDIT: I know that I could potentially get outlets set up via a viewcontroller, but Apple states that UIViewController is for full-screen views only, and my widget is only taking up a small portion of the screen.

  • 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-15T14:49:32+00:00Added an answer on June 15, 2026 at 2:49 pm

    You have done correctly. And one thing is, In iOS it’s not widget.It’s a UIView.

    (Sorry there may be any typo in my code.I have written myself in StackOverflow)

    Follow Below Steps to finish it..

    1) After you have created the xib for the view, then you need to have a UIView subclass files.. For example your xib name likes this CustomView.xib means then create a files like this CustomView.m and CustomView.h

    2) In your CustomView.xib , You need to set the fileOwner as your CustomView.h.

    3) In your CustomView.m file, there will be a method like initWithFrame: In that method you need to load your xib file like this

    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomView" owner:self options:0];
    UIView *currentView = [topLevelObjects objectAtIndex:0];
    [self addSubView:currentView];
    

    4) Almost over. In any of your view controller, you can use this xib like

    CustomView *newSubView = [[CustomView alloc]initWithFrame:CGRectMake(0,0,55,67)];
    [self.view addSubView:newSubView];
    

    That’s it.. Go on..

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

Sidebar

Related Questions

For an MVC3 application I want to create a reusable DAL that is accessed
In my application I want to create one Search widget which would be Reusable
I'm looking to create a reusable function that will generate a random key with
I want to create a helper method that can take in ANY type of
I want create wordpress website into which I want create user management... That means
i want create a custom json data from the mssql 2008 results so that
I want create an application with animate button? how can i do? after click
i want create Dynamic Slideshow in Jquery i'm Write this code var ctx =
How do I create a reusable library/module in XCode 3.2? What I want to
I'm trying to create a reusable UserControl in WPF that has a Label and

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.