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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:05:12+00:00 2026-05-22T22:05:12+00:00

Hey all… I have a view controller (A) which on some action, alloc init’s

  • 0

Hey all… I have a view controller (A) which on some action, alloc init’s another view controller (B) and then adds B’s view to its view as a subview. So now ViewController B’s view is a subview of ViewController A. The problem I have is If I simply remove B’s view from A it seems to still stick around for example. View B contains a web view, when I load a video on the webView, even after I remove the view from view Controller A’s view I can still hear the video??

How can I destroy viewcontroller B and remove its subview from A? Im finding this tricky as I dont really push it onto a navigationcontroller’s stack which I can just pop from… I hope this makes sense, if not please say and I will try and clarify.

Many thanks

Jules

 -(void)showNewsWebView:(int)index {

NewsWebViewController *myWebView = [[[NewsWebViewController alloc] initWithNibName:@"NewsWebViewController" bundle:nil]autorelease];

//setup webview with request etc

[[self.view.superview superview] addSubview:myWebView.view];
myWebView.alpha = 0.
[UIView beginAnimations:@"test" context:nil];
[UIView setAnimationDuration:.3];
myWebView.view.alpha = 1.;
[UIView commitAnimations];

}

//called after delegate callback from webviewcontroller
- (void)newsWebViewDismissedView:(NewsWebViewController *)controller {
[UIView beginAnimations:@"test" context:nil];
[UIView setAnimationDuration:.3];
controller.view.alpha = 0.0;
[self performSelector:@selector(removeView:) withObject:controller.view afterDelay:.5];

[UIView commitAnimations];
}

-(void) removeView:(UIView *)view {
[view removeFromSuperview];
view = nil;
}
  • 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-22T22:05:13+00:00Added an answer on May 22, 2026 at 10:05 pm

    Does ViewController B really need to be a ViewController?

    If you’re adding subviews you should probably have B subclass UIView instead of UIViewController. Adding B’s view as a subview essentially negates any advantage you’d have of B being a ViewController.

    Anyway to answer your question. You might want to make viewcontroller B an ivar of A so that viewcontroller A can manage the memory of viewController B. Once you remove the view of B from A, you can release viewcontroller B from memory (I still don’t support this as it sounds like ineffective code. You should probably state what you’re aiming to do, and post some code as to how you’re doing it so we can help you out better 🙂 )

    EDIT:

    From your code seems like you should just be pushing and popping. Are you using MyWebViewController just to show a webpage? You might be better off using a simple UIWebView.

    I also noticed something wrong in your animation code for setting alpha to 0. If you want some method to be executed after an animation ends you should use the following code:

    //called after delegate callback from webviewcontroller
    - (void)newsWebViewDismissedView:(NewsWebViewController *)controller {
    [UIView beginAnimations:@"test" context:nil];
    [UIView setAnimationDuration:.3];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(removeView)];
    
    controller.view.alpha = 0.0;
    
    [UIView commitAnimations];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all, I have something of an interesting requirement for my project. I need
Hey all - I have an app where I'm authenticating the user. They pass
Hey all. I have a server written in java using the ServerSocket and Socket
Hey all i've tried to add an other view it work properly but it
hey all.i'm newbie at this problem.i have this data in table result: item range_code
Hey all, weird question. My company has an application from another company that records
Hey all! Ive got timezone troubles. I have a time stamp of 2010-07-26 23:35:03
Hey all of you PHP geeks, and hackers, if some of you listen ;o)
Hey all, my Computational Science course this semester is entirely in Java. I was
Hey all. Newbie question time. I'm trying to setup JMXQuery to connect to my

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.