Objective c iPhone:图像水平库

Objective c iPhone:图像水平库,objective-c,ios4,uiscrollview,uiimage,Objective C,Ios4,Uiscrollview,Uiimage,我试图在填充真实数据之前创建示例库 float xAxis = 0; float mostHeight = self.galleryView.bounds.size.height; for (int i = 0; i < 5; i++) { //getImage from url UIImage* myImage = [UIImage imageWithData: [NSDa

我试图在填充真实数据之前创建示例库

    float xAxis = 0;
    float mostHeight = self.galleryView.bounds.size.height;
    for (int i = 0; i < 5; i++) {

        //getImage from url
        UIImage* myImage = [UIImage imageWithData: 
                            [NSData dataWithContentsOfURL: 
                             [NSURL URLWithString: @"http://4.bp.blogspot.com/-M9k3fhlUwmE/TdYgxL97xMI/AAAAAAAAAY8/_r45zbAm1p0/s1600/CARTOON_Cat-full.jpg"]]];
        myImage = [[MyMath sharedMySingleton] imageWithImage:myImage convertToSize:CGSizeMake(mostHeight - 10, mostHeight - 10)];
        //set image
        UIImageView *rview= [[UIImageView alloc] initWithImage:myImage];
        /*adding the view to your scrollview*/
        [self.galleryView addSubview:rview];
        xAxis += myImage.size.width + 20;
    }
    //set scrolling area
    self.galleryView.contentSize = CGSizeMake(xAxis, mostHeight);
float xAxis=0;
float mostHeight=self.galleryView.bounds.size.height;
对于(int i=0;i<5;i++){
//从url获取图像
UIImage*myImage=[UIImage imageWithData:
[NSData DATA with contents sofURL:
[NSURL URLWithString:@”http://4.bp.blogspot.com/-M9k3fhlUwmE/TdYgxL97xMI/AAAAAAAAAY8/_r45zbAm1p0/s1600/CARTOON_Cat-full.jpg"]]];
myImage=[[MyMath sharedMySingleton]imageWithImage:myImage convertToSize:CGSizeMake(mostHeight-10,mostHeight-10)];
//设置图像
UIImageView*rview=[[UIImageView alloc]initWithImage:myImage];
/*将视图添加到滚动视图中*/
[self.galleryView addSubview:rview];
xAxis+=myImage.size.width+20;
}
//设置滚动区域
self.galleryView.contentSize=CGSizeMake(xAxis,mostHeight);
galleryView是来自xib的UIScrollView。在这里,我试图将5张相同的图片填充到图库中,但它只填充了一张图片和之后的空间(因为xAxis编号)。我做错了什么


另外,我是iPhone sdk的新手,所以不要评判我

你从来没有为
UIImageView
设置框架。您需要通过图像视图的宽度+填充来偏移
frame
frame.origin.x
)的
x
原点的
坐标。

您忘了将imageView的帧设置为x轴的x偏移。

您能告诉我更多信息吗。我真的是iPhone sdk中的noob。我知道你想说什么,但不知道如何得到它。你希望UIImageView的大小与从UIScrollView看到的相同,还是希望它们的大小可变,但高度=UIScrollView的高度?