gpt4 book ai didi

iphone - iPhone 中的 UIScrollView?

转载 作者:行者123 更新时间:2023-11-28 20:28:31 26 4
gpt4 key购买 nike

我在 iPhone 应用程序中工作,使用 UIScrollView 设置水平,在 UIScrollView 中添加 5 个图像,并且工作正常。(我想在开放时间显示第二张图片)然后我尝试在屏幕显示时显示第二张图片。但是我尽力了,但是我没有那样做,请任何人帮助我

提前致谢

我试过这个:

 UIScrollView *scroll1 = [[UIScrollView alloc] initWithFrame:CGRectMake(10, 45, 300, 360)];
scroll1.contentSize=CGSizeMake(2700, 360);
[scroll1 setShowsHorizontalScrollIndicator:NO];
scroll1.pagingEnabled=YES;
[self.view addSubview:scroll1];

UIImageView *SlideImage = [[UIImageView alloc]initWithFrame:CGRectMake(0,0, 300, 360)];
SlideImage.image=[UIImage imageNamed:@"img1.png"];
SlideImage.backgroundColor=[UIColor clearColor];
[scroll1 addSubview:SlideImage];

UIImageView *SlideImage1 = [[UIImageView alloc]initWithFrame:CGRectMake(300,0, 300, 360)];
SlideImage1.image=[UIImage imageNamed:@"img2.png"];
SlideImage1.backgroundColor=[UIColor clearColor];
[scroll1 addSubview:SlideImage1];

UIImageView *SlideImage2 = [[UIImageView alloc]initWithFrame:CGRectMake(600,0, 300, 360)];
SlideImage2.image=[UIImage imageNamed:@"img3.png"];
SlideImage2.backgroundColor=[UIColor clearColor];
[scroll1 addSubview:SlideImage2];

UIImageView *SlideImage3 = [[UIImageView alloc]initWithFrame:CGRectMake(900,0, 300, 360)];
SlideImage3.image=[UIImage imageNamed:@"img4.png"];
SlideImage3.backgroundColor=[UIColor clearColor];
[scroll1 addSubview:SlideImage3];

UIImageView *SlideImage4 = [[UIImageView alloc]initWithFrame:CGRectMake(1200,0, 300, 360)];
SlideImage4.image=[UIImage imageNamed:@"img5.png"];
SlideImage4.backgroundColor=[UIColor clearColor];
[scroll1 addSubview:SlideImage4];

UIImageView *SlideImage5 = [[UIImageView alloc]initWithFrame:CGRectMake(1500,0, 300, 360)];
SlideImage5.image=[UIImage imageNamed:@"img6.png"];
SlideImage5.backgroundColor=[UIColor clearColor];
[scroll1 addSubview:SlideImage5];

最佳答案

试试这个

[scroll1 setContentOffset:CGPointMake(300, 0) animated:FALSE];

关于iphone - iPhone 中的 UIScrollView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13171957/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com