开发者

adding UIImageView to UIScrollView

开发者 https://www.devze.com 2023-03-05 13:32 出处:网络
I have a UIScrollView set up in IB. I am adding in a UIImageView to it in viewDidLoad method but it\'s not working. Here\'s my code:

I have a UIScrollView set up in IB. I am adding in a UIImageView to it in viewDidLoad method but it's not working. Here's my code:

- (void)viewDidLoad {
    [super viewDidLoad];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
    [scrollView addSubview:imageV开发者_如何学Goiew];
    [scrollView setContentSize:[imageView frame].size];
    [imageView release];
}

I NSLog-ed imageView and it's not null. What am I doing wrong? Thanks.

EDIT: The screen is just blank. There's nothing there.


It sounds like your UIScrollView isn't hooked up. Is the outlet for scrollview valid? Log scrollView to verify.

0

精彩评论

暂无评论...
验证码 换一张
取 消