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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:02:00+00:00 2026-06-07T20:02:00+00:00

How do I add or remove a view from a TableView? I want it

  • 0

How do I add or remove a view from a TableView?

I want it to come up with “No Connections” whenever there is nothing in the tableView, but then when there is data, I just want a normal tableView.

I’ve checked lots of questions, all of which had strange ways of removing views from cells and doing everything in a cell.
However, I also found that you can, in Xcode, drag a UIView into a tableView, and it will scroll with it.

When you do that, and you want to get rid of the view, you simply set the hidden property of that view to be true.

The problem here is that then there is white space where the view once was. I want it to completely go away and not be there, but adding/removing subviews didn’t work for me. I tried lots of other solutions as well.

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

    I found that you can simply put that View into the bucket in Xcode, but not in the view controller. (See pic)

    Not in the view controller

    Then, I found that if I made an outlet to that UIView, I could still use it.
    Note that I had to design the view and make it the proper size, etc either programatically, or in IB before I moved it to this position, since I cannot see it anymore in IB.

    Then, in the TableViewController class, I used ViewWillAppear to check the count of the array that backs up the TableView. If it was zero, I set the view (using the Outlet) to be hidden or not.

    Next, I used this code:

    -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        if (noConnectionView.hidden)
        {
            return 0;
        } else {
            return 480;
        }
    }
    
    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    {
        if (noConnectionView.hidden)
        {
            return nil;
        } else {
            return noConnectionView;
        }
    }
    

    This makes it fill my popover, and since the number of cells for section method returns the same count that I already checked (which is zero, if the table is empty) that is the only thing displayed (no empty cells).

    When there are things to display, ViewWillAppear is called each time (and whenever things are deleted, I call view will appear again) and then the tableView gets rid of the header and it behaves like a normal tableView.

    This is great because you can use it with a UITableViewController or in sequence with a navigation controller.

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

Sidebar

Related Questions

Im trying to add a subview, and then also remove the previous view. here
I try to remove a view from it's superview after being animated offscreen. But
I am trying to add/remove UILabels to a ScrollView. The adding takes place just
So I want to be able to add/remove class methods at runtime. Before you
I know that whenever you add/remove/modify any file in the App_Code, App_GlobalResources, and bin
Is there a way in any browser to add/remove class names? For example, if
I'm trying to add a custom view to an UITableView created with code from
I have very custom TableView like Add Contact View in iPhone's Contacts. I like
Best method to add/remove webcontrols or user controls in asp.net for dynamic forms without
How to register listening for any Contact (add/remove contact, change in email/phone ) changes

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.