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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:40:01+00:00 2026-06-09T20:40:01+00:00

I am wondering what happens if a single instance of a UIView object gets

  • 0

I am wondering what happens if a single instance of a UIView object gets added as a subview of multiple other views simultaneously.
If UIView:removeFromSubview: gets called then does it get removed from all superviews or just the currently displayed one?

For background:

I have a status-bar like view object that needs to be displayed within several different other views (each other view is managed by its own view controller).

[i.e. a) the user is in one view, b) something happens to make the status-bar-like view appear, c) the user switches to another view d)the status bar is still visible in the new view e) the status bar expires after a time and disappears from site. And so on]

Initially I implemented this by adding/removing it as required as a subview of the window, and this was managed by a singleton.
However due to some complications with some animations I have instead added it as a subview of each of the main view’s for each of the view controllers.
Note that there are not multiple copies

When the view needs to be removed I am calling its removeFromSuperview:, and everything is all working perfectly.

However I am wondering what the situation is regarding the removal of the view, is it being fully removed or is there something else I need to do?

For example the view might get added to N view controller’s views by calling addSubview as required (it will only get added to each view controller if that view controller actually launches)
However when it is being removed I am only calling removeFromSuperview: for the view of currently loaded view controller, not all view controllers it might have been added to.

Next time I navigate to one of these other view controllers it displays fine without the view being there, even though I didn’t explicitly call removeFromSuperView.

As I said everything is working as it is, however at the back of my mind I feel there might be something missing?

Hope this was understandable.

  • 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-09T20:40:03+00:00Added an answer on June 9, 2026 at 8:40 pm

    You can only have it added to one view. Documentation is your friend!

    • (void)addSubview:(UIView *)view:
      Views can have only one superview. If view already has a superview and that view is not the receiver, this method removes the previous superview before making the receiver its new superview.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wondering what happens when I use a MKReverseGeocoderDelegate in my ViewController, but the
I'm wondering what happens after the constructor is done executing my code, because the
I'm going through the django tutorials and I was wondering what happens when you
I was wondering if anyone happens to know of a jQuery (or pure javascript)
I was wondering if there was any resources available online that explains what happens
I was wondering what happens if from the kernel (Linux in this case) you
I'm just wondering what happens in the case of a time zone changing, when
I am wondering what happens if I lazy load Google Analytics JavaScript few seconds
Regarding setting up script maps on IIS, I am wondering what happens if I
It often happens that a single C# solution contains some projects that are x86-specific

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.