tags:

views:

15

answers:

1

hi all, i am using the following code to scroll image on scrooll view,

StoryViewScroller = [[[UIScrollView alloc] initWithFrame:CGRectMake(0.0f, 79.0f, 320.0f, 262)] autorelease];
StoryViewScroller.contentSize = CGSizeMake(NPAGES * 320.0f, StoryViewScroller.frame.size.height);
StoryViewScroller.pagingEnabled = YES;
StoryViewScroller.delegate = self;
StoryViewScroller.showsHorizontalScrollIndicator = NO;
StoryViewScroller.scrollsToTop = YES;
// Load in all the pages
for (i = 0; i < NPAGES; i++)
{
    NSString *filename = [NSString stringWithFormat:@"%d.jpg", i+1];
    UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:filename]];
    iv.frame = CGRectMake(i * 320.0f, 0.0f, 320.0f, 262);
    [StoryViewScroller addSubview:iv];
    NSLog(@"I is :: %d" ,i);
    [iv release];
}

[self.view addSubview:StoryViewScroller];

this enable mein tos scroll view from left to right and vice versa.what should i change to sroll view to top to bottom and vice versa.

sugggestions

regards

+1  A: 

To enable vertical scrolling set appropriate height to the contentSize, e.g.

StoryViewScroller.contentSize = CGSizeMake(320.0f, NPAGES*StoryViewScroller.frame.size.height);
Vladimir
it works but getting only 1 images ....
shishir.bobby
sure - you need to set correct frame to your image views - change y origin coordinate instead of x in a loop. something like: iv.frame = CGRectMake(0.0f, i*262.0f, 320.0f, 262);
Vladimir
yea..how stupid i m.....thanks Vladimir. can i show 2 images at a time???. like its 1 image at a time is coming up, wat if, want to show 2 or three images on a view
shishir.bobby