我已经设置了一个UIScrollView并加载在图片中,并将其设置为与图片之间存在一些偏移的视图相等。有人可以解释我可能做错了什么吗?它显示的第一张照片很好,但不会让我滚动左右看到下一个。我需要一个新的XCode手势识别器来完成这项工作吗?UIScrollView与生成的图片
- (void)viewDidLoad
{
[super viewDidLoad];
int PageCount = 3;
UIScrollView *Scroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
Scroller.backgroundColor = [UIColor clearColor];
Scroller.pagingEnabled = YES;
Scroller.contentSize = CGSizeMake(PageCount = Scroller.bounds.size.width, Scroller.bounds.size.height);
CGRect ViewSize = Scroller.bounds;
UIImageView *ImgView = [[UIImageView alloc] initWithFrame:ViewSize];
[ImgView setImage:[UIImage imageNamed:@"1.png"]];
[Scroller addSubview:ImgView];
ViewSize = CGRectOffset(ViewSize, Scroller.bounds.size.width, 0);
UIImageView *ImgView2 = [[UIImageView alloc] initWithFrame:ViewSize];
[ImgView2 setImage:[UIImage imageNamed:@"2.png"]];
[Scroller addSubview:ImgView2];
ViewSize = CGRectOffset(ViewSize, Scroller.bounds.size.width, 0);
UIImageView *ImgView3 = [[UIImageView alloc] initWithFrame:ViewSize];
[ImgView3 setImage:[UIImage imageNamed:@"3.png"]];
[Scroller addSubview:ImgView3];
[self.view addSubview:Scroller];
}
@end
如果你有'页页次= Scroller.bounds.size.width',你可能是打算'页页次* Scroller.bounds.size.width' – Rob
哎呦!对不起,谢谢你! –