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

  • Home
  • SEARCH
  • 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 8869651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:31:49+00:00 2026-06-14T17:31:49+00:00

I’ve scrollview with many image button, for the button 1-8 there’s no problem on

  • 0

I’ve scrollview with many image button, for the button 1-8 there’s no problem on button behaviour. it can be log which is clickable.

the problem is button on 2nd page look like not listening on selector (button 9-10). it possible problem from pagecontrol? or i missed something here?

    // button paging
myImages = [NSArray arrayWithObjects:
                     [UIImage imageNamed:@"img_1.png"],
                     [UIImage imageNamed:@"img_2png"],
                     [UIImage imageNamed:@"img_3.png"],
                     [UIImage imageNamed:@"img_4.png"],
                     [UIImage imageNamed:@"img_5.png"],
                     [UIImage imageNamed:@"img_6.png"],
                     [UIImage imageNamed:@"img_7.png"],
                     [UIImage imageNamed:@"img_8.png"],
                     [UIImage imageNamed:@"img_9.png"],
                     [UIImage imageNamed:@"img_10.png"],
                     nil
            ];

// prepare counter
int posX, posY = 5, counter = 0, pages = 0;
BOOL reset = NO;

// uiviewscroller
CGRect scrollFrame;
scrollFrame.origin.x = self.myScrollView.frame.size.width * pages;
scrollFrame.origin.y = 0;
scrollFrame.size = self.myScrollView.frame.size;

UIView *subView = [[UIView alloc] initWithFrame:scrollFrame];
subView.backgroundColor = [UIColor colorWithRed:232.0f/255.0f green:233.0f/255.0f blue:235.0f/255.0f alpha: 1];

// loop over images
for (int i = 0; i < myImages.count; i++)
{
    counter++;

    // reposition X
    if (counter == 1 || counter == 5)
    {
        posX = 4;

        // more than 1 page
        if (pages > 0)
            posX = 320 * pages;
    }
    else
    {
        posX += 80;
    }

    // reposition Y
    posY = (counter <= 4) ? 5 : 85;

    if (reset == YES)
    {
        // reflag
        reset = NO;

        // redefined size
        scrollFrame.origin.x = self.myScrollView.frame.size.width * pages;            
    }

    // create image view for button
    UIImage *myIcon = [myImages objectAtIndex:i];
    UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];

    // manipulate button behavior
    myButton.frame = CGRectMake(posX, posY, 80, 80);
    [myButton setTitle:[NSString stringWithFormat:@"%d", i] forState:UIControlStateNormal];
    [myButton setImage:myIcon forState:UIControlStateNormal];
    [myButton addTarget:self action:@selector(btnClicked:) forControlEvents:UIControlEventTouchUpInside];

    // add image to subview
    [subView addSubview:myButton];

    if (counter == 8)
    {
        // reset position
        posX = 4;
        posY = 5;

        // populate counter
        counter = 0;
        pages++;

        // reset section
        reset = YES;

        // add subview to view
        [self.myScrollView addSubview:subView];
    }

    // add balance subview to scroller
    if (counter > 0 && i == myImages.count-1)
    {
        // add subview to view
        [self.myScrollView addSubview:subView];
        pages++;
    }
}

scrollFrame.origin.x = self.myScrollView.frame.size.width * pages;
self.myScrollView.contentSize = CGSizeMake(self.myScrollView.frame.size.width * pages, self.myScrollView.frame.size.height);
self.myPaging.numberOfPages = pages;
  • 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-06-14T17:31:51+00:00Added an answer on June 14, 2026 at 5:31 pm

    You are adding buttons on a view called subView. Last two buttons are getting added outside the bounds of this view as view’s frame is equal to scrollview’s frame (UIView *subView = [[UIView alloc] initWithFrame:scrollFrame];).

    Change its frame after adding buttons-

    Add the line below at the end where you are changing content size of scroll view.

    [subView setFrame:CGRectMake(subView.frame.origin.x, subView.frame.origin.y, _scrollView.frame.size.width * pages, _scrollView.frame.size.height)];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I am currently running into a problem where an element is coming back from
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.