Loading UIImageView in a UITableViewCell Accessory View

I have a jpg image called Check Mark.jpg that I am trying to load into the accessory view of a table cell. This is my code now:

 cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Check Mark.jpg"]]; 

in cellForRowAtIndexPath method

When I do this, nothing is displayed in the table view cell. I checked the file name and tried to put it in the folder containing the .xcodeproj file and the folder containing all the code files. None of them worked. I also tried to declare UIImageView and UIImage as strong properties and initialize them in the init: method. None of this is happening. I can display the disclosure button in the view, so I know there is an accessory view, but I can’t figure out how to display this simple image.

Do I have to somehow upload the image to my project?

+4
source share
1 answer

After adjusting the image, try setting the next frame.

Something like that:

 cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Check Mark.jpg"]]; [cell.accessoryView setFrame:CGRectMake(0, 0, 15, 15)]; 

I think the accessoriesView frame is set to 0.

+5
source

Source: https://habr.com/ru/post/1496702/


All Articles