no visible interface error

Discussion in 'iOS Programming' started by Kapthehat, Sep 20, 2013.

  1. Kapthehat macrumors member

    Joined:
    Jul 1, 2013
    #1
    Hello - wonder if any of you can help me with the following code:-


    Code:
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        
        cell.textLabel.text = self.characters[indexPath.row];
        if (cell.accessoryView ==nil)
        {
            UIImage *buttonUpImage = [UIImage imageNamed:@"button_up.png"];
            UIImage *buttonDownImage = [UIImage imageNamed:@"button_down.png"];
            UIImage *button= [UIButton buttonWithType:UIButtonTypeCustom];
            [button setBackgroundImage:buttonUpImage forState:UIControlStateNormal  ];
         [COLOR="SandyBrown"]   [button setBackgroundImage:buttonDownImage forState:UIControlStateHighlighted];[/COLOR]
            
        }
    
    
    I get an "No visible interface for UIImage declares the selector setBackgroundImage ..." - but I cant see why ? thanks

    regards

    Kaps
     
  2. Guiyon macrumors 6502a

    Joined:
    Mar 19, 2008
    Location:
    North Shore, MA
    #2
    Looks through your code again, carefully. Why type are you declaring the 'button' variable to be?
     
  3. Kapthehat thread starter macrumors member

    Joined:
    Jul 1, 2013
    #3
    thanks - bit of a newbie.

    I am declaring button to be 'UIButton' - if I understand your question properly ?
     
  4. Guiyon macrumors 6502a

    Joined:
    Mar 19, 2008
    Location:
    North Shore, MA
    #4
    Not quite. You are assigning an instance of UIButton to the 'button' variable, but the 'button' variable is declared as a different type. What does the it say to the left of 'button' on the line where you are calling the buttonWithType: method?
     
  5. Kapthehat thread starter macrumors member

    Joined:
    Jul 1, 2013
    #5
    no visible interface !!

    thank you ... should be UIButton rather than UIImage !!!

    ----------

    cc
     

Share This Page