UIImageViewビアストーリーボードを作成し、@propertyそれをに追加すると、ビアまたはのどこからでもViewController.hアクセスできます。UIImageViewViewController.m[self UIImageView]self.UIImageView
しかし、以下のようにUIImageViewプログラムで作成viewDidLoadすると、外部からアクセスできなくなったようですviewDidLoad。
UIImageView *prevImgView = [[UIImageView alloc] init];
UIImageView *currImgView = [[UIImageView alloc] init];
UIImageView *nextImgView = [[UIImageView alloc] init];
NSArray *imageViews = [NSArray arrayWithObjects:prevImgView, currImgView, nextImgView, nil];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
[self.view addSubview: scrollView];
CGRect cRect = scrollView.bounds;
UIImageView *cView;
for (int i=0; i<imageViews.count; i++) {
cView = [imageViews objectAtIndex:i];
cView.frame = cRect;
[scrollView addSubview:cView];
cRect.origin.x += cRect.size.width;
}
そのため、後でUIImageView作成した画像のいずれかに表示されている画像を変更したい場合viewDidLoad、アクセスできないようです。誰かが私が間違っていることを知っていますか?