Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Kapthehat

macrumors member
Original poster
Jul 1, 2013
51
0
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
 
thanks - bit of a newbie.

I am declaring button to be 'UIButton' - if I understand your question properly ?
 
thanks - bit of a newbie.

I am declaring button to be 'UIButton' - if I understand your question properly ?

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?
 
no visible interface !!

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

----------

cc
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.