程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> ios-iphone中的UIScrollView問題

ios-iphone中的UIScrollView問題

編輯:編程綜合問答
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];

最佳回答:


試試這:

[scroll1 setContentOffset:CGPointMake(300, 0) animated:FALSE];
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved