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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:34:33+00:00 2026-05-20T14:34:33+00:00

@Jonah pointed me to the following explanation he has provided: Question on View Controller's

  • 0

@Jonah pointed me to the following explanation he has provided:
Question on View Controller's view

I currently have a MainViewController whose main(root?) view contains an Add Record UIButton which is linked to the following method and is dependent on which page the user currently has open in a UIScrollView:

#pragma mark -
#pragma mark Add View Support

- (void)add:(id)sender {

MyAddViewController *controller = nil;

    // Dynamically creating and allocating the Add View Controller
if (dataViewPageControl.currentPage == 0) {
    controller = [[MyAddViewController alloc] initWithAddType:1];
} else {
    controller = [[MyAddViewController alloc] initWithAddType:0];
}

controller.delegate = self;

    // Slide the new AddViewController's view in from the right
    CGPoint initialCenter = self.view.center;
controller.view.center = CGPointMake(initialCenter.x + 320, initialCenter.y);
[self.view addSubview:controller.view];

[UIView beginAnimations:@"animation" context:NULL];
[UIView setAnimationDuration:0.35];
[UIView setAnimationDelegate:controller];
controller.view.center = CGPointMake(initialCenter.x, initialCenter.y);
[UIView commitAnimations];

}

MainViewController is the delegate for MyAddViewController (which has a CANCEL/CLOSE button) and when it’s close button is clicked the MyAddViewController is released through the close method in this MainViewController.

As you can see, MyAddViewController’s view becomes a subview to the current root view (Bad? Bad? Bad?) MyAddViewController’s view is as a FULL size view (320×416) but whose top half is transparent, so that MainViewController’s view can be seen below on the top half and the bottom half contains the AddViewController’s view and textfields etc….

Based on what I’ve read from @Jonah just now at the link at the very top this sort of design is BAD, BAD, BAD. I’ve noticed when testing in Instruments that MyAddViewController sometimes lags when sliding in. I’ll click the ADD button to fire this method and there is sometimes a 3 – 5 sec delay before the view slides in. Some sort of delay in all the memory management and cleanup?

I’m assuming I can fix this by making a single MyAddViewController property inside MainViewController which will then prevent me from allocating and deallocating on every button click. That should make things smoother? My only worry is that this will cause a greater memory imprint at application load time. Instruments seems to show a 516KB allocation every time I click ADD for the first time in my app.

Any recommendations though on design and how to improve this? The reason I like having separate view controllers with nested views like this is because MyAddViewController has a lot of logic with Core Data and such and MainViewController is pretty busy enough already as it is. Trying to keep things modular.

Thanks in advance!

  • 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-20T14:34:34+00:00Added an answer on May 20, 2026 at 2:34 pm

    I think the best solution is to redesign your MyAddViewController to be a controller which inherits from NSObject rather than UIViewController. The MyAddViewController can then manage a subview of your MainViewController allowing you to keep your controller logic nicely encapsulated without abusing UIViewController.

    I’ve tried to describe why nesting the views of multiple custom UIViewController classes is problematic here: http://blog.carbonfive.com/2011/03/09/abusing-uiviewcontrollers/

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

Sidebar

Related Questions

I currently have an svn repository on my hosted web server. I work locally,
The css of a major site I am looking at has what appears to
I have just downloaded the latest xdebug for my windows machine running wamp and
I have some text configuration file that need to be read by my program.
Using phpmyadmin, I changed the password for user root (both the localhost entry and
I have created a simple Servlet that I want to deploy in Jetty 7.2.
I am using Eclipse IDE for Java Developers Helios. I have mainly done desktop
Does anyone know of an existing method of automatically cleaning the indentation of a
(Final solution at the bottom) I am trying to set up an iPad app
My problem is related with what Jonas asked on the next topics: How to

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.