Removing highlight from a selected row in UITable

Discussion in 'iOS Development' started by stratocaster2006, Apr 1, 2008.

  1. stratocaster2006

    stratocaster2006 New Member

    Joined:
    Dec 26, 2007
    Messages:
    22
    Likes Received:
    0
    hi there, I have a problem I would like some suggestions on from any dev on the board.

    I would like to remove the highlight from a selected row (and of course Unselect that row) after a refresh on a UITable.

    So far I was not able to locate any calls that allow removal of the highlight. There are calls to select the highlighted row, even the previous highlighted row, but no calls that I'm aware of to remove the highlight (and the row selection).

    What I want to implement can be seen in action in the audioplayer: select Albums, then select an album name (the row with the albumname will highlight and you will be dropped into the view that shows all songs on that album. Then select Album on the top bar to go back to the Albums overview and you will see that the highlight on the selected album fades away.

    Anyone know how to implement this ? Any suggestion would be appreciated
    --gsan
  2. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Just tap somewhere else. But true it is kind of anoying.
  3. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    I am at work now, so I can't give you an exact call, but off the top of my head, I am coming up with this.

    Code:
    [cell setSelected:NO withFade:YES]
    Although just programmatically selecting row 0 is also supposed to work, I keep getting errors, so I gloss right over it.

    Edit: put the above call in the callback for the tableRow selected function.
  4. curthard89

    curthard89 New Member

    Joined:
    Sep 15, 2007
    Messages:
    178
    Likes Received:
    1
    Device:
    iPhone 3GS (Black)
    i read around that selecting row -1 does the trick
  5. stratocaster2006

    stratocaster2006 New Member

    Joined:
    Dec 26, 2007
    Messages:
    22
    Likes Received:
    0
    hi SkylarEC, tried the [cell setSelected:NO withFade: YES]; in the - (UITableCell*)table

    Please Register or Log in to view images

    UITable*)table cellForRow

    Please Register or Log in to view images

    int)row column

    Please Register or Log in to view images

    int)column call.

    Even preceded it with a [cell updateHighlightColors]; No joy.

    --gsan
  6. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Alright, I'll post some code when I get home from w
    work.
  7. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Here you go:

    Code:
    
    [[[notification object]cellAtRow:[[notification object]selectedRow]column:0] setSelected:FALSE withFade:TRUE];
    
    
  8. stratocaster2006

    stratocaster2006 New Member

    Joined:
    Dec 26, 2007
    Messages:
    22
    Likes Received:
    0
    hi skylarEC,

    thanks for the code snippet, that does indeed fade out the selection right after selecting the row. Now I just need to figure out how I can keep the selection and fade out _after_ I come back from a details view. That would just be some eye candy, but when I go back to the higher level (after dropping into a details view) it would give a nice clue as to which row I was on before selection and details view. I will probably have to send a selectRow message, will look into this after work.

    thanks again,

    --gsan
  9. Abcmsaj

    Abcmsaj Retired Moderator

    Joined:
    Jan 26, 2008
    Messages:
    5,501
    Likes Received:
    122
    Device:
    iPhone 6 Plus
    Thanks Skylar.
    Helped me too

    Please Register or Log in to view images

  10. stratocaster2006

    stratocaster2006 New Member

    Joined:
    Dec 26, 2007
    Messages:
    22
    Likes Received:
    0
    Selecting row -1 and then reloading the table also rids you of the selection, so curthard89 was right. Thsi avoids that the selection pops up after a reload of the table.

Share This Page