-1
我在Xcode中製作遊戲,我需要在屏幕上顯示分數。我將分數顯示爲圖像而不是使用普通字體。這是到目前爲止我的代碼:如何在UIImageView中顯示NSMutableArray
NSString *score = @"132";
NSMutableArray *images = [[NSMutableArray alloc]initWithCapacity:score.length];
for (int i = 0; i < score.length; i++) {
// imageName will be @"1", then @"3" and @"2"
NSString *imageName = [[score substringToIndex:i] substringToIndex:1];
// add extension
imageName = [imageName stringByAppendingString:@".png"];
UIImage *image = [UIImage imageNamed:imageName];
[images addObject:image];
}
我該如何獲得NSMutableArray
顯示在UIImageView
因此它顯示在頂部的主要故事板。我試過這樣的東西:
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, imagescore.size.width, imagescore.size.height)];
imageView.image = images;
我不知道任何方式顯示任何形式的視圖NSMutableArray。您可能能夠在圖像視圖中顯示數組的某些*內容*,但沒有人會關心這些內容是來自數組還是其他地方。 –