我有,稍微简化:
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0,
200 /*self.view.frame.size.width*/,
(self.view.frame.size.height - 20) / 3)];
UIImage *cardImage = [UIImage imageNamed:@"note1"];
CGSize cardSize = [cardImage size];
CJSHCardView *cardView = [[CJSHCardView alloc] initWithImage:cardImage];
[cardView rotate];
[cardView setContentMode:UIViewContentModeScaleAspectFit];
[cardView setFrame:CGRectMake(0, 20, cardSize.width * scale, cardSize.height * scale)];
[cardView setDescription:@"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"];
[cardView setOnWeb:[NSURL URLWithString:@"https://www.google.com"]];
[scrollView addSubview:cardView];
for(int i = 0; i < 10; ++i)
{
UIImage *noteImage2 = [UIImage imageNamed:@"note2"];
CGSize noteSize2 = [noteImage2 size];
UIImageView *imageView2 = [[UIImageView alloc] initWithImage:noteImage2];
CGRect bounds2 = imageView2.bounds;
CJSHCardView *noteView2 = [[CJSHCardView alloc] initWithImage:noteImage2];
[noteView2 rotate];
[noteView2 setContentMode:UIViewContentModeScaleAspectFit];
[noteView2 setFrame:CGRectMake(100 + 100 * i, 20, noteSize2.width * scale, noteSize2.height * scale)];
[scrollView addSubview:noteView2];
}
[containerView addSubview:scrollView];
在 200 像素宽或注释掉的宽度下,它会显示一定数量的图像,最右边的图像会被截断。但是, UIScrollView 不滚动。我试过左右(单)手指滑动,图像没有移动一个像素。
这里有什么问题?我是否需要进行额外的配置才能获得类似轮播的滚动?是否有更好的类来实现在单个维度上滚动的轮播?
谢谢,