how to stop button from changing image when table cell selected

Discussion in 'iOS Development' started by cybohemia, Jul 18, 2009.

  1. cybohemia

    cybohemia New Member

    Joined:
    Jan 25, 2009
    Messages:
    49
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
    I created a TableViewCell with a button in it that has an image dependent on the mode the app is in.

    However, when the cell is selected (cell turns blue) without the mode changing, the image is changed anyway although I want it to remain the same. Is there an implicit changing of a button's state or something when its parent cell is selected?

    I am using

    Code:
    [cell.expandButton setImage:[UIImage imageNamed:@"image2.png"] forState:UIControlStateNormal];
    (and I also added a line for (UIControlStateHighlighted | UIControlStateDisabled | UIControlStateSelected) but it made no difference).

    It's in the cellForRowAtIndexPath routine, where the cell is defined.

    Am I missing something basic or doing something fundamentally wrong? Any help or insights greatly appreciated - thanks!
  2. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    Adding a button to a UITableViewCell?

    I'd take the approach os subclassing it instead.
  3. cybohemia

    cybohemia New Member

    Joined:
    Jan 25, 2009
    Messages:
    49
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
    It is subclassed. (I just left that part out - sorry.) It's the subclass that has the additional stuff, like the button.
  4. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    And I take it expandButton is a UIButton?
  5. cybohemia

    cybohemia New Member

    Joined:
    Jan 25, 2009
    Messages:
    49
    Likes Received:
    0
    Device:
    iPhone 3G (Black)
    Yes - expandButton is a UIButton

Share This Page