- (void)viewDidLoad {
[super viewDidLoad];
[self playaudios];
[btnimage setImage:image1 forState:UIControlStateNormal];
[scrollView1 setBackgroundColor:[UIColor blackColor]];
[scrollView1 setCanCancelContentTouches:YES];
scrollView1.delaysContentTouches=YES;
scrollView1.indicatorStyle = UIScrollViewIndicatorStyleWhite;
scrollView1.clipsToBounds = YES; // default is NO, we want to restrict drawing within our scrollview
scrollView1.scrollEnabled = YES;
// pagingEnabled property default is NO, if set the scroller will stop or snap at each photo
// if you want free-flowing scroll, don't set this property.
scrollView1.pagingEnabled = YES;
// load all the images from our bundle and add them to the scroll view
NSUInteger i;
NSLog(@" ImageLoad&&&&&&&&&&&&&");
for (i = 1; i <= kNumImages; i++)
{
NSString *imageName = [NSString stringWithFormat:@"movimg%d.png", i];
UIImage *image1 = [UIImage imageNamed:imageName];
UIButton *btnimage = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
[btnimage setImage:image1 forState:UIControlStateNormal];
//btnimage.image=image;
//imageView = [[UIImageView alloc] initWithImage:image];
//[imageView setUserInteractionEnabled:YES];
[scrollView1 setUserInteractionEnabled:YES];
// setup each frame to a default height and width, it will be properly placed when we call "updateScrollList"
NSLog(@"Image11111111....................");
CGRect rect = btnimage.frame;
rect.size.height = kScrollObjHeight;
rect.size.width = kScrollObjWidth;
NSLog(@"Image222222222....................");
btnimage.frame = rect;
btnimage.tag = i;
NSLog(@"Image333333333....................");// tag our images for later use when we place them in serial fashion
[scrollView1 addSubview:btnimage];
NSLog(@"Image444444444....................");
[btnimage release];
NSLog(@"Image555555555....................");
}
[self layoutScrollImages];
}
- (void)layoutScrollImages
{
NSLog(@"layoutScrollImages");
UIButton *view = nil;
NSArray *subviews = [scrollView1 subviews];
NSLog(@"layoutScrollImages1111111111111");
// reposition all image subviews in a horizontal serial fashion
CGFloat curXLoc = 0;
NSLog(@"layoutScrollImages222222222222222");
for (view in subviews)
{
if ([view isKindOfClass:[UIButton class]] && view.tag > 0)
{
CGRect frame = view.frame;
frame.origin = CGPointMake(curXLoc, 0);
view.frame = frame;
curXLoc += (kScrollObjWidth);
}
NSLog(@"curXLoc.........=%f",curXLoc);
}
}