0

ビューが正常に読み込まれているスクロールビューがありますが、スクロールしていません。誰でも理由がわかりますか?

   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;
4

1 に答える 1

1

scrollviewをスクロール可能にするには、contentSizeプロパティを設定して、すべてのコンテンツを含めることができるようにする必要があります(おそらく、scrollviewフレームよりも大きくなります)。たとえば、ビューを水平方向にスクロールする場合は、contentSizewidthを画像ビューの数の倍数に設定する必要があります。

...
// Loaded data and created subviews
// Now set contentSize
[scrollView setContentSize:CGSizeMake(imageWidth*numberOfImages, self.view.frame.size.height)];
于 2012-04-27T08:57:20.177 に答える