UIButton image working on simulator but not on the device
ios, objective-c, uibutton
Solution
Check your image name, because simulator is not case sensitive but the device is case sensitive.
Problem
I have an app where there is a `UITableView` populated UIButtons that are created programatically. The code below shows how one `UIButton` is created. It works perfectly on the simulator but not on the device. On the simulator the buttons are displayed with the buttonImage.png shown but on the device the image is not there. All other aspects of the buttons are correct. The image has been added to the resources correctly as far as I can tell. Any ideas? ``` - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; if (cell ==nil) { cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } UIButton * button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button setFrame:CGRectMake(0,0,160, 160)]; [button setBackgroundImage:[UIImage imageNamed:@"buttonImage.png"] forState:UIControlStateNormal]; [button setTitleColor:[UIColor colorWithRed:19/255.0f green:73/255.0f blue:17/255.0f alpha:1] forState:UIControlStateNormal]; button.titleLabel.font = [UIFont fontWithName:@"arial" size:20]; [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchDown]; [button setTitle:@"button" forState:UIControlStateNormal]; //more buttons created as needed NSMutableArray *buttonArray = [[NSMutableArray alloc] init]; [array addObject:button]; //more buttons added to array as needed [cell addSubview:[buttonArray objectAtIndex:indexPath.row]]; return cell; ``` }