我正在嘗試加載與用戶選擇的表視圖行/單元對應的圖像和標籤。該代碼出現在我的DetailViewController實現文件中,如下所示:聲明需要用switch語句表達整型(int無效)錯誤
- (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語句如上所述產生錯誤。我已經在這裏和其他地方尋找解決方案而沒有成功。任何幫助是極大的讚賞!
「characterNumber」的聲明是什麼?這是唯一重要的事情。 –