2 vikeytoy vikeyToy 于 2012.11.01 17:04 提问

iphone中的UIScrollView问题

我在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];

1个回答

love_loveec
love_loveec   2012.11.02 10:17
已采纳

试试这:

[scroll1 setContentOffset:CGPointMake(300, 0) animated:FALSE];
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!