使用.plist中定义的特殊字符加载图像

时间:2012-09-10 17:01:41

标签: ios xcode

我有一个包含很多名字的.plist 表格视图显示.plist中的所有信息 此外,还会将与该字符串同名的图像添加到单元格中。

几乎一切正常,只有具有特殊字符的名称才会显示图像。

工作:
<string>The Name</string>
我有一个名为“The Name.png”的图像

有效。

不工作:
<string>The Name vs. "Me"</string>
我有一个名为“The Name vs.”Me“.png”

的图像

图像未显示。

为什么? 我怎样才能使它发挥作用?

感谢。

添加所要求的信息。

plist中。
<dict>
<key>Name</key>
<string>A</string>
<key>type</key>
<array>
<string>The Name</string>
<string>The Name vs. "Me"</string>
</array>
</dict>

将图像调用到单元格的代码 UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
imgView.image = [UIImage imageNamed:nombreDeDOEnFila];
cell.imageView.image = imgView.image;

更多代码以显示其使用方式。

// Configure the cell.
NSString *nombreDeDOEnFila = [type objectAtIndex:row];
cell.textLabel.text = nombreDeDOEnFila;

// Call image
UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
imgView.image = [UIImage imageNamed:nombreDeDOEnFila];
cell.imageView.image = imgView.image;

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSString *nombreDeDOEnFila = [type objectAtIndex:row];
moreInfoController.name = nombreDeDOEnFila;

1 个答案:

答案 0 :(得分:0)

plist编辑器中的字符串是未转义的字符串。你将不得不逃避报价

<string>The Name vs. \"Me\"</string>