UITableView in UIScrollview

Discussion in 'iOS Programming' started by IDMah, Jul 25, 2013.

  1. IDMah macrumors 6502


    May 13, 2011
    Hi all.

    I have two tableviews (high local & global score) on a scrollview.

    When call the table on it's own would work like a charm.. :
     [myTable scrollToRowAtIndexPath:indexPath
                           atScrollPosition:UITableViewScrollPositionTop animated:YES];
    but now it's on the scrollview, nothing happens. When I sort or try to ScrollToRow. nothing!
    but it will update when I add/delete an entry.

    Do I have to call scrollToRow from the within the scrollView?


    ps. I would be cool to trigger a scrollToRow when I switch screens

    I guess??? Something in :
    -(void)scrollViewDidScroll:(UIScrollView *)sender
     // do the tableview ScrollToRow thang //
  2. erdinc27 macrumors regular

    Jul 20, 2011
    i faced similar problem when i used an UITableview in an UIScrollView. The UITableView didnt move when i try to scroll it down or up. i searched over web and saw many people faced the same problem. it was because of Auto Layout. i dont know if u need Auto Layout in your case but in mine i turned off Auto Layout and the UITableView worked.
  3. MattInOz macrumors 68030


    Jan 19, 2006
    Why do you want to put a tableview inside a scrollview. A tableview already has a scrollview within it.

    You mention two tableviews, which way are they arranged?
    If vertical why not just have two sections on the same tableview. Which might make more sense as both are displaying score data from what you said so cells could be reused between anyway.

    Or are the tables next to each other?

    Not sure if it's AutoLayout sounds more like your container scrollview is canceling the swipe guestures so that it never gets passed to the scrollview of the tableview. Just a hunch.
  4. IDMah, Aug 1, 2013
    Last edited: Aug 2, 2013

    IDMah thread starter macrumors 6502


    May 13, 2011
    table up down scroll left right.

    Sorry work getting in the way with work... Hahaa.!!!

    I have two vertically scrolling Table views, on a horizontally scrolling paged scrollview.

    Since I already created the High Score Table view, I figured I'd just slap another version on a Scrollview and all would be copacetic.

    Main problem is that the Tableview isn't getting updated, when I add the user's score. Pretty close to dumping it all and using game Centre. sigh...

    Just noticed an warning in this: Assigning to id '<UITableViewDelegate>' from type 'HighScoreViewControl'

    [myHighScoreTable sortUsingDescriptors:
         [NSMutableArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"gameTime" 
    this doesn't give me an error:
     NSSortDescriptor *hisort = [NSSortDescriptor sortDescriptorWithKey:@"gameTime" 
        NSMutableArray *sortDescriptors = [NSMutableArray arrayWithObject: hisort];
        [myHighScoreTable sortUsingDescriptors:sortDescriptors];
    but still doesn't work..

    I see the inserted HighScore Value but does not seem to update after sort.
    Double checked I was doing a sort after insert.. which I do.
    Also Doesn't scroll to either.

  5. IDMah, Aug 4, 2013
    Last edited: Aug 4, 2013

    IDMah thread starter macrumors 6502


    May 13, 2011
    Little things


    Ok Here's what I did to fix it.

    I changed the XIB to make the Scrollview a little bigger, because I read somewhere if the view on the UIScrollview is bigger than the Scrollview then the view never gets triggered/Updated.

    Also changed the sort to sort numerically, not string. So this:
     NSSortDescriptor *hisort = [NSSortDescriptor sortDescriptorWithKey:@"gameTimeSeconds" 
    Now everything scrolls and triggers. So for now copasetic, now back to the php, Mysql and other stuff. Less fun stuff.


Share This Page