为什么这张图片没有添加到我的滚动视图中?

时间:2013-02-28 09:21:59

标签: iphone ios objective-c xcode cocoa-touch

为什么这张图片没有添加到我的UIScrollView?正在显示白色屏幕:

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.scrollView.frame.size.width * 1, 0, self.scrollView.frame.size.width, self.scrollView.frame.size.height)];
    imageView.backgroundColor = [UIColor redColor];
    [imageView setImage:[UIImage imageNamed:@"placeholder.png"]];
    [self.scrollView addSubview:imageView];
    self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * self.urlArray.count, self.scrollView.frame.size.height);

1 个答案:

答案 0 :(得分:3)

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.scrollView.frame.size.width, self.scrollView.frame.size.height)];

并提供contentSize UIScrollView UIScrollViewUIView添加{{1}}