-1

我正在尝试加载与用户选择的表格视图行/单元格相对应的图像和标签。代码出现在我的 DetailViewController 实现文件中,如下所示:

- (void)viewDidLoad
{
[super viewDidLoad];

//Create a couple of UIImages
UIImage *jenImage = [UIImage imageNamed:@"102_2262.jpg"];
UIImage *jen2Image = [UIImage imageNamed:@"102_2288.jpg"];
UIImage *paigeImage = [UIImage imageNamed:@"102_2332.jpg"];
UIImage *parkerImage = [UIImage imageNamed:@"102_2379.jpg"];

//Switch UIImages and UILabel based on characterNumber
switch (characterNumber) {
    case 0:
        characterName.text = @"Casual Jen";
        characterPic.image = jenImage;
        self.title = @"Casual Jen";
        break;
    case 1:
        characterName.text = @"Dressed Up Jen";
        characterPic.image = jen2Image;
         self.title = @"Dressed Up Jen";
        break;
    case 2:
        characterName.text = @"Paige";
        characterPic.image = paigeImage;
        self.title = @"Paige";
        break;
    case 3:
        characterName.text = @"Parker";
        characterPic.image = parkerImage;
        self.title = @"Parker";
        break;
    default:
        characterName.text = @"Parker";
        characterPic.image = parkerImage;
        self.title = @"Parker";
        break;
    }
}

switch 语句会产生所描述的错误。我已经在这里和其他地方寻找解决方案但没有成功。任何帮助是极大的赞赏!

4

1 回答 1

1

将数据类型characterNumber设为 int。

于 2013-01-12T05:23:31.227 回答