2010-07-16 65 views
1

我有一個滾動視圖,其中有一個UIView,其中包含內容。我添加了一個UIImageView作爲UIScrollView的子版本(所以它應該位於內容容器的頂部),並且這適用於iPhone 3.2或更高版本,但在運行3.1.3的iPhone上,圖像不會顯示在容器上方。我的代碼是這樣的:addSubview在iOS 3.1.3上不顯示視圖

// add the content container 
    UIView *contentContainer = [[UIView alloc] init]; 
    [scrollView addSubview:contentContainer]; 

    // add content, etc 

    // this works in 3.2+ 
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; 
    [scrollView addSubview:imageView]; 
    // tried adding this for 3.1, but still didn't work 
    [scrollView bringSubviewToFront:imageView]; 
    [imageView setFrame:CGRectMake(point.x, point.y, image.size.width, image.size.height)]; 

是否還有別的東西我失蹤?謝謝!

+0

升級到4.0:D – jmont 2010-07-16 17:01:34

回答

0

發現的問題:當我指定的圖像的名字,我沒有指定圖像擴展:

UIImage *image = [UIImage imageNamed:@"myImage"]; 

如果我改變了以下內容,它的工作原理:

UIImage *image = [UIImage imageNamed:@"myImage.png"]; 

確實的iOS知道如果擴展名偶然出現,仍然可以查找「@ 2x」版本?

0

您是否也在設置UIScrollViewcontentSize屬性?