ios的scrollview cunundrum

我有一个成功的视图填充滚动视图,但它不滚动,任何人都可以看到为什么?

CGRect fullScreenRect=[[UIScreen mainScreen] applicationFrame]; UIScrollView *scrollView=[[UIScrollView alloc] initWithFrame:fullScreenRect]; [scrollView setContentSize:self.view.frame.size]; if (sqlite3_open(dbpath, &xxx) == SQLITE_OK) { // code that works if (sqlite3_prepare_v2(xxx, query_stmt, -1, &statement, NULL) == SQLITE_OK) { while (sqlite3_step(statement) == SQLITE_ROW) { //more code that works //add image view to view [scrollView addSubview:myImageView]; i = i + 1; } sqlite3_finalize(statement); } sqlite3_close(xxx); } self.view=scrollView; 

为了使滚动视图可滚动,你需要设置它的contentSize属性能够包含所有的内容(所以最有可能比滚动视图框大)。 例如,如果您想要水平滚动视图,则需要将contentSize宽度设置为图像视图数量的倍数:

 ... // Loaded data and created subviews // Now set contentSize [scrollView setContentSize:CGSizeMake(imageWidth*numberOfImages, self.view.frame.size.height)];