didSelectRowAtIndexPath and Table View

Discussion in 'iOS Programming' started by yaboy10holla, Feb 25, 2011.

  1. yaboy10holla, Feb 25, 2011
    Last edited by a moderator: Feb 26, 2011

    yaboy10holla macrumors newbie

    Joined:
    Feb 19, 2011
    #1
    Please Help!

    I'm trying to program a row in UITableview (added as a subview of another object) to show/hide other objects when tapped. this is how i tried to do it

    Code:
    - (void)tableView:(UITableView *)tableView
    didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    	if ([groupList didSelectRowAtIndexPath:0]) {
    		crowdInfoTwo.hidden=NO;
    }
    
    This is unsuccessful. I'd realllly appreciate a push in the right direction.

    thanks
     
  2. dantastic macrumors 6502

    dantastic

    Joined:
    Jan 21, 2011
    #2
    Can you give a bit mode detail what you are trying to achieve here? And what the variables actually are? Second, I'd add some NSLoging to see what is called when I tap a row:

    Code:
    
    - (void)tableViewUITableView *)tableView didSelectRowAtIndexPathNSIndexPath *)indexPath {
       NSLog(@"Row %i in section %i has been tapped", indexPath.row, indexPath.section);
       if ([groupList didSelectRowAtIndexPath:0]) {
          NSLog(@"If statement true");
          crowdInfoTwo.hidden=NO;
       }
    
    
    What is groupList & crowdInfo? What does didSelectRowAtIndexPath return?
     
  3. yaboy10holla thread starter macrumors newbie

    Joined:
    Feb 19, 2011
    #3
    sure sorry. groupList is the name of the UITableView, and crowdInfoTwo is a UIScrollView I want to show and hide.

    i'm just having trouble getting the rows of the table to "do" something when I tap them, in this case, showing a UIScrollView
     
  4. forum user macrumors regular

    Joined:
    Aug 28, 2008
    #4
    Code:
    - (void)tableView:(UITableView *)tableView
    didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    	[B]if (indexPath.row == 0) [/B]{
    		crowdInfoTwo.hidden=NO;
                   }
    }
    
    Note that indexPath has a .row and a .section. That will be of interest if your tableview has more than one section.

    - Olaf
     

Share This Page