Weird issue with adding a subview on top of a UITableView

Discussion in 'iOS Programming' started by AndyCodez, Mar 17, 2010.

  1. AndyCodez macrumors regular

    Joined:
    Aug 6, 2009
    #1
    Basically what I am trying to do is place a subview on top of a UITableView. I have a class that adds a subview to what ever view you pass it.

    Code:
    [activityPopUpView startActivity:self.view]
    
    - (void) startActivity:(UIView*) theView
    {
        [theView addSubview:self.aview];
    }
    
    
    I have used this in the past for displaying an UIActivityView, and it worked fine. But I've needed to use this on top of a UITableView for loading information off of the interwebz. I checked the subview stack and it appears there but it will not show on top. Even with bringsubviewtofront.

    Is there some weird property I am missing that will not place the subview on top of the tableview?

    The code I placed earlier is just written off the top of my head its not exactly what I have, but the code has worked fine elsewhere where there is not a UITableView. My thinking is the cells are still overtop of this view and the subview I am trying to display is just covered by said cells. I have called this code in the viewdidload when the data is being brought in from the internet and parsed. which shows when there is no cells currently being displayed. But once there are cells currently being shown the subview being called will not be displayed.

    The instance of the class in the viewdidload is not the same as the new instance being called after the cells are shown.

    Edit: I have tried using self.table instead of self.view (self.table is the UITableView)

    Please help this is driving me nuts!
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    Don't addSubview to a table view. If you want to put an activity view or something like it on top of the table addSubview the container view that's below the table view. You may need to move the view to the front of the table.

    The table view is a scrollview and its contents are dynamic. There's no way to work around those things.
     
  3. AndyCodez thread starter macrumors regular

    Joined:
    Aug 6, 2009
    #3
    Yeah I figured as such, I was just giving it ago. I've been doing

    Code:
    [self.view addSubview:self.activityView];
    
    Which was not working so i did

    Code:
    [self.view addSubview:self.activityView];
    [self.view bringSubviewtoFront:self.activityView];
    
    And that still doesn't work..... grr So frustrated :(
     
  4. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    Do you have a container view behind the table view?
     
  5. AndyCodez thread starter macrumors regular

    Joined:
    Aug 6, 2009
    #5
    I just have a UIView.

    EDIT: I ended up figuring out what I needed to do, run the activityView on a different thread. Doing this it worked just fine... I'll have to do some more reading on the situation but it works.
     

Share This Page