我已經設置了一個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
哎呦!對不起,謝謝你! –