6

I have an jpg image named Check Mark.jpg that I'm trying to load into the accessory view of a table view cell. This is what my code currently is:

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

in the cellForRowAtIndexPath method

When I do this, nothing displays in the table view cell. I have checked the name of the file, and have tried putting it in the folder containing the .xcodeproj file and the folder containing all the code files. Neither of these have worked. I also tried declaring the UIImageView and UIImage as strong properties and initializing them in the init: method. None of this works. I can display the detail disclosure button in the view, so I know the accessory view is there, but I can't seem to figure out how to display this simple image.

Do I have to somehow load the image into my project?

4

1 回答 1

6

设置图像后,尝试设置框架。

像这样的东西:

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

我认为附件视图框架设置为 0。

于 2013-08-13T03:59:09.153 回答