UIImageView
ビアストーリーボードを作成し、@property
それをに追加すると、ビアまたはのどこからでもViewController.h
アクセスできます。UIImageView
ViewController.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
、アクセスできないようです。誰かが私が間違っていることを知っていますか?