Its so simple i am giving you a method use this directly only make object in header file
@property (weak, nonatomic) IBOutlet UIScrollView *scrollViewImages;
after create method loadImages
-(void)loadImages
{
_scrollViewImages.contentSize = CGSizeMake(arrayAdImages.count*_scrollViewImages.frame.size.width,0);
_scrollViewImages.pagingEnabled=YES;
if(arrayAdImages.count>0)
{
int xOrigin = 0;
for(int i =0; i<[arrayAdImages count]; i++)
{
NSString*img=[arrayAdImages objectAtIndex:i];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.tag = i;
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
button.frame = CGRectMake(xOrigin, 0, 768 ,768);
}
else{
button.frame = CGRectMake(xOrigin, 0, 320 ,320);
}
NSString *image=[NSString stringWithFormat:@"%@",img];
image= [image stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"image url tesing %@",image);
[button setBackgroundImageForState:UIControlStateNormal withURL:[NSURL URLWithString:image]];
if (i==0) {
[imgUrlForSharing setImageWithURL:[NSURL URLWithString:image]];
}
[_scrollViewImages addSubview:button];
xOrigin = xOrigin + _scrollViewImages.frame.size.width;
button.contentMode=UIViewContentModeScaleAspectFill;
}
}
double delayInSeconds = 1.3;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[[_scrollViewImages viewWithTag:1356] removeFromSuperview];
});
_scrollViewImages.showsHorizontalScrollIndicator=false;
_scrollViewImages.showsVerticalScrollIndicator=false;
}
(currentPage+1)*scroll.frame.width;
set this tocontent offset
. – Blind Ninja