所以我声明一个 NSMutableArray 来保存 5 个 UIImageViews。
.h 文件:
@interface ImageDisplay : UIViewController {
IBOutlet UIImageView *img1;
IBOutlet UIImageView *img2;
IBOutlet UIImageView *img3;
IBOutlet UIImageView *img4;
IBOutlet UIImageView *img5;
NSMutableArray *imageHolderArray;
}
@property (nonatomic, retain) IBOutlet UIImageView *img1;
@property (nonatomic, retain) IBOutlet UIImageView *img2;
@property (nonatomic, retain) IBOutlet UIImageView *img3;
@property (nonatomic, retain) IBOutlet UIImageView *img4;
@property (nonatomic, retain) IBOutlet UIImageView *img5;
@property (nonatomic, retain) IBOutlet NSMutableArray *imageHolderArray;
@end
在 .m 文件中:
//All objects are synthesized, just easier not to crowd the screen
- (void)viewDidLoad {
[super viewDidLoad];
imageHolderArray = [[NSMutableArray alloc] initWithObjects: img1,img2,img3,img4,img5,nil];
NSLog(@"imageHolderArray count: %i",[imageHolderArray count]); //Returns count of 1
}
所以我的问题是,为什么会这样?为什么它不拾取 Array 中的所有对象?我不精通Objective-C编程,所以如果有人能在此处提示我,我将不胜感激。谢谢你。