Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6881347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:05:46+00:00 2026-05-27T05:05:46+00:00

i will like to add in a background image bgImageView.image = [UIImage imageNamed:@frame_trans]; for

  • 0

i will like to add in a background image bgImageView.image = [UIImage imageNamed:@"frame_trans"]; for each image in the scrollview, however the scroll view expand instead of adding the image behind each image, what have i do wrong ?

EDIT: working code added, thanks to ColdLogic.

this is my old scroll view

enter image description here

i wanna add in a paperclip

enter image description here

but the current code do this.

enter image description here

CODE:

//init scrollview in location on screen
//scrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(30, 100, 278, 290)];   
//scrollview.backgroundColor = [UIColor redColor];
//pass image filenames
NSMutableArray *fileNames = Info.imageFiles; //[[[NSMutableArray alloc] init] autorelease];
//setup the array of uiimageviews
NSMutableArray *imgArray = [[NSMutableArray alloc] init];
NSMutableArray *bgImgArray = [[NSMutableArray alloc] init];       
//loop through the array imgNames to add file names to imgArray
for (NSString *imageName in fileNames) {
    NSString *tempIMGName = [NSString stringWithFormat:@"data/%i/%@",Info.ID, imageName];
    NSLog(@"tempIMG %@",tempIMGName);
    UIImageView *imageView = [[UIImageView alloc] init];
    UIImageView *bgImageView = [[UIImageView alloc] init];;
    imageView.image = [UIImage imageNamed:tempIMGName];
    bgImageView.image = [UIImage imageNamed:@"frame_trans"];
    imageView.contentMode = UIViewContentModeScaleAspectFit;
    CGAffineTransform newTransform = CGAffineTransformMakeRotation((CGFloat)(-3 * M_PI / 180.0));
    imageView.layer.affineTransform = newTransform;//CGAffineTransformMakeRotation(degreesToRadians(10));
    [imgArray addObject:imageView];
    [bgImgArray addObject:bgImageView];
    [imageView release];
    [bgImageView release];
}

CGSize pageSize = scrollview.frame.size; 

NSUInteger page = 0;

for (UIView *bgViewForScrollView in bgImgArray) {

    [scrollview addSubview:bgViewForScrollView];

    bgViewForScrollView.frame = CGRectMake(pageSize.width * page++ +10, 0, pageSize.width -20 , pageSize.height);


    // making use of the scrollView's frame size (pageSize) so we need to;
    // +10 to left offset of image pos (1/2 the gap)
    // -20 for UIImageView's width (to leave 10 gap at left and right)

}

NSUInteger page1 = 0;
for (UIView *viewForScrollView in imgArray) {

    [scrollview addSubview:viewForScrollView];
    viewForScrollView.frame = CGRectMake(pageSize.width * page1++ +10, 0, pageSize.width -20 , pageSize.height);

    // making use of the scrollView's frame size (pageSize) so we need to;
    // +10 to left offset of image pos (1/2 the gap)
    // -20 for UIImageView's width (to leave 10 gap at left and right)
}

//add scroll view to view
[self.view addSubview:scrollview];
[self.view bringSubviewToFront:scrollview];
scrollview.contentSize = CGSizeMake(pageSize.width * [imgArray count], pageSize.height);

//scrollview.contentSize = CGSizeMake(320 *viewcount + 20, 290 );
scrollview.showsHorizontalScrollIndicator =NO;
[scrollview setPagingEnabled:YES];
scrollview.delegate =self;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:05:47+00:00Added an answer on May 27, 2026 at 5:05 am

    The problem is that you are using page++ when you are create the frames for the background views and then not resetting it when you start creating the frames for the images. page will have a value of 3 going into the for loop for the imgArray, making it place it at a 4th index.

    for (UIView *bgViewForScrollView in bgImgArray) {
        //code
    }
    
    //ADD THIS LINE OF CODE
    page = 0;
    
    for (UIView *viewForScrollView in imgArray) {
        //Code
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Horizontal Scroll View, dynamically i will add items in to that.
@include linear-gradient(color-stops(#e2e2e2, #fff 600px), top); will generate something like background-image: -webkit-gradient(linear, 0% 0%, 0%
If I add a full text index in PostgreSQL, will my LIKE and ILIKE
I have a PHP file which will return something like <div id=title>Add Us On
Is there any way to pad a repeating background image that will not also
I would like to use an image for background in the canvas element provided
Here's my css link for images: background-image:url(images/background.gif); I just want to add some: ../
I have a view that has a background image and a CGPath that gets
I am trying to create a options button above my scroll view that will
I have UINavigationBar subclassed and I add a custom background like so: @implementation CustomUINavigationBar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.