Image In Scroll View


UIScrollView*scrollview;-(void)anyFunction
{
    scrollview =[[UIScrollView alloc] initWithFrame:CGRectMake(0,30,320,50)];NSInteger viewcount =[cat_Products count];// if you have four content your view count is 4..(four)..in my case i fetch it from databaseCGFloat y2 =0;UIView*view;UIImageView*imageView;NSString*imageName;for(int i =0; i< viewcount; i++){CGFloat y = i *64;  
        y2 = y2 +64;

        view =[[UIView alloc] initWithFrame:CGRectMake(y,0, y2,50)];

        imageName =[[NSString alloc] initWithFormat:@"c%i",(i +1)];// my image name is c1, c2, c3, c4 so i use thisUIImage*image1 =[UIImage imageNamed:imageName];   
        imageView =[[UIImageView alloc] initWithImage:image1];[view addSubview:imageView];[scrollview addSubview:view];[view release];[imageView release];[imageName release];}    

scrollview.contentSize =CGSizeMake(viewcount*64,0);//viewcount*64 because i use image width 64..and  second parameter is 0..because i not wants vertical scrolling... [myView addSubview:scrollview];[scrollview release];}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s