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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:10:47+00:00 2026-06-15T23:10:47+00:00

I am unclear on how to reuse view controllers. If you have created a

  • 0

I am unclear on how to reuse view controllers. If you have created a view controller subclass that does some stuff (doesn’t really matter what it does, just that it does what you need in the view), can it be used with a different view or should it be subclassed again?

In other words, if I need the exact same functionality in a view in a different part of my app, can I use the original view controller and just add the outlets from the new view? Or should I subclass the custom controller and give the view its “own” view controller?

  • 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-15T23:10:48+00:00Added an answer on June 15, 2026 at 11:10 pm

    You could create two xibs for the view controller.

    If you have the files…

    MyViewController.m
    MyViewController.h
    

    Then you could add the xibs…

    MyViewControllerXib1
    MyViewControllerXib2
    

    Just make the “File’s Owner” MyViewController.

    Then when you need the UI layout from the first XIB you can call…

    MyViewController *controller = [[MyViewController alloc] initWithNibName:@"MyViewControllerXib1" bundle:[NSBundle mainBundle]];
    

    When you need the second UI you can call…

    MyViewController *controller = [[MyViewController alloc] initWithNibName:@"MyViewControllerXib2" bundle:[NSBundle mainBundle]];
    

    The object you get will be the same but the nib laying out the UI will change.

    ANOTHER APPROACH

    Just thinking out loud here.

    You could also create a ViewController without a nib.

    Then create two subclasses of this each WITH a nib. Now you have code reuse and separate layouts but you can also make fine control tweaks to each of the subclasses of your “master” controller.

    You can then create as many subclasses as you like from this master view controller.

    USING STORYBOARDS

    Just drag a new ViewController object onto the storyboard. Change the class to be the view controller class and set up the UI and drag the controls to the code etc… You will then have two screens that look different but share the same functionality code.

    This is just the same as what I said at first but using storyboard instead.

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

Sidebar

Related Questions

I'm unclear on the best way to have multiple view models that derive from
I am still unclear about which adapter to use in a situation that doesn't
I'm writing a simple little game for my kids - it doesn't really matter
My question may be a bit unclear, but I have extended the View class
I still have some unclear understand about release and autorelease. What are the difference
I have a view that - among other things - contains a list of
Sorry for unclear subject but i really don't understand where problem. I use a
Sorry for an unclear question previously; hopefully I can start again... I have this
This is a bit unclear to me... So, if I have a function: char
I am a little unclear on how to rotate views that are sitting on

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.