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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:45:38+00:00 2026-06-13T18:45:38+00:00

I have a master-detail controller for my app. The master controller is a UITabBarController

  • 0

I have a master-detail controller for my app. The master controller is a UITabBarController and each tab is a UITableViewController that contains different types of data.

I plan on having a main header / image on the main detail view but then need to add different subviews to the main detail view to detail specific information depending on which tab I am using.

I am currently adding the relevant subview in my

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

Function like so:

UIViewController *subview = [[UIViewController alloc] initWithNibName:@"ItemNotFoundViewController" bundle:nil];
subview.view.frame = CGRectMake(20, 160, subview.view.frame.size.width, subview.view.frame.size.height);  
[self.detailViewController.view addSubview:subview.view];

However, I believe that this is a poor way of doing things – every time someone clicks on a table cell another subview will be thrown on top of the stack of previously added subviews, creating memory issues.

What I am wondering is, does ARC take care of this for me? Is my approach passable? and even if it is passable, is there a better way of doing this?

  • 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-13T18:45:39+00:00Added an answer on June 13, 2026 at 6:45 pm

    First of all, no. ARC does not take care of this for you. It’s not it’s purpose to do that and even if it was, how could it know, that you don’t want the previously added subviews anymore?
    You have to remove those subviews yourself and then ARC will take care of deallocating them (if there are no other references to them).

    Anyway that’s not the way you’re supposed to use a UISplitViewController (the master-detail view controller). As you noticed the split view controller handles two other view controllers. The master- and the detailViewController. In most cases the master view controller isn’t changing while the app runs (it’s content changes, but usually that’s handled by a container view controller like UINavigationController which is assigned as the masterViewController), but the detail view controller does.

    Instead of adding subviews to your existing detailViewController you should replace it by a new one. So you should create separate XIBs (what you’ve apparently done already) for all the view controllers that you want to present in the detail-section. And modify your code to

    self.detailViewController = newDetailViewController; //newDetailViewController would be the vc you called subview in your code
    

    instead of

    [self.detailViewController.view addSubview:subview.view];
    

    Edit: Notice that this assumes that your detailViewController property does ‘the right things’ when you set it’s value. By default the UISplitViewController only has a property called viewControllers which is an NSArray in which the first object is the masterVC and the second is the detailVC.

    Take a look at MultipleDetailViews for an example of how to manage that.

    Since you want to have a header view in all your detail view controllers you have various choice of achieving that (which may or may not be applicable in your case, depending on your design):

    • add the header view to every details vc’s XIB
    • instead of creating many XIBs for all detailVCs, create a new custom UIViewController subclass that modifies it’s content based on some parameters you give it, i.e. which tableViewCell was tapped by the user
    • create a custom container view controller that manages two child view controllers, one for the headline and one for the content above it.

    For more information about UISplitViewController and custom container view controller, please refer to:

    View Controller Basics

    Creating Custom Container View Controllers

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

Sidebar

Related Questions

In my iPhone Core Data app I have it configured in a master-detail view
I have a split view-based app that presents a master-detail interface, and uses a
I have a data model that consists of a master - detail relationship where
I have a master-detail app that is working great for the iPad. However, the
I have a master detail Application in xCode. In Master View Controller an Array
When using a spilt view controller, I have a Master and Detail View. When
I have a splitViewController that has a master and detail view controllers. The code
I have a classic master-detail scenario that I am implementing in backbone.js. For the
I have an iPad master-detail where the main detail controller is a navigation controller
I am wondering if it is okay to have master and detail table for

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.