0

私はUIPageViewController5つのスクリーンを持っています。下の画像をご覧ください

ここに画像の説明を入力

Screen #1Screen #2などのラベルの代わりに画像を追加する必要があります。

これが私のコードです

誰か解決策を教えてください。

4

1 に答える 1

0

このコードを試してください..

imageArray 配列に任意の画像を追加します。

NSArray *imageArray=[[NSArray alloc]initWithObjects:@"SpaceTheme.png",@"BeachTheme.png",@"vintage.png", nil];

ScrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320,480)];
[Scroll setPagingEnabled:YES];
[Scroll setShowsHorizontalScrollIndicator:NO];

for(n=0; n< [imageArray count];n++)
   {

    NSString *imageName=[imageArray objectAtIndex:n];

        NSString *fullImageName=[NSString stringWithFormat:@"%@",imageName];
        CGRect imageViewFrame;



            int padding=20;
            imageViewFrame=CGRectMake(Scroll.frame.size.width*n+padding-10,Scroll.frame.origin.y-130,Scroll.frame.size.width-1*padding, Scroll.frame.size.height);


        UIImageView *imageView=[[UIImageView alloc]initWithFrame:imageViewFrame];

        [imageView setImage:[UIImage imageNamed:fullImageName]];

        [imageView setContentMode:UIViewContentModeScaleAspectFit];

        [Scroll addSubview:imageView];

        pagecontrol.numberOfPages = 3;   // Give numbre of pages here 
        pagecontrol.currentPage = 0;

        [self.view addSubview:pagecontrol]; 
    }
    Scroll.delegate=(id)self;
    CGSize scrollViewSize=CGSizeMake(Scroll.frame.size.width*[imageArray count], Scroll.frame.size.height);
    [Scroll setContentSize:scrollViewSize];
    [self.view addSubview:Scroll];
于 2013-10-09T07:18:46.947 に答える