Ipad 将imageView加载到scrollView时出现问题

Ipad 将imageView加载到scrollView时出现问题,ipad,uiscrollview,uiimageview,uiimage,Ipad,Uiscrollview,Uiimageview,Uiimage,我是Objective-c的新用户。我无法将imageview加载到scrollview 我使用界面生成器将滚动视图添加到视图中。然后我尝试通过代码在scrollview上添加一个imageview UIImage*image=[[UIImage alloc]init]autorelease]; image=[UIIamge imagename:@“cover.jpg”] imageView=[[UIImageView alloc]init]autorelease]; imageVIew.fra

我是Objective-c的新用户。我无法将imageview加载到scrollview

我使用界面生成器将滚动视图添加到视图中。然后我尝试通过代码在scrollview上添加一个imageview

UIImage*image=[[UIImage alloc]init]autorelease]; image=[UIIamge imagename:@“cover.jpg”]

imageView=[[UIImageView alloc]init]autorelease]; imageVIew.frame=CGRectMake(50.0,40.0,200.0200.0); imageView.image=图像

[ScorlView添加子视图:imageView]

然后我在ScrollView上添加另一个imageView,位置为(50.01000.0) 长度=200,宽度=200(ipad的屏幕为786*1004) 照片可以显示在屏幕上。第二张照片不完整,我尝试滚动屏幕,但无法滚动


谢谢

您必须增加contentinset或UIScrollview以使其可滚动, 你可以增加底部

scorllView.contentInset = UIEdgeInsetsMake(0, 0, 680, 0);
或者根据需要增加

首先,您只需要

UIImage*image=[UIImage ImageName:@“cover.jpg”]
类方法(ImageName:here)创建它的实例而不是“alloc”将创建一个自动释放的对象

[UIImage ImageName:@“cover.jpg”] 在概念上与
[[UIImage alloc]initWithFileContents:@“cover.jpg”]自动释放]//注意,分配一次,发布一次。
(内部可能不相同,ImageName:缓存图像initWithFileContents:可能不相同)

要滚动滚动滚动视图, 有很多事情你需要确保

其中之一是确保scrollView的内容大小大于scrollView的帧大小。
尝试设置scrollView.contentSize=CGSizeMake(someBigValue,someBigValue)

scrollView中的内容在scrollView中滚动。因此,您的内容应该大于scrollView的帧大小才能滚动