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 8337323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:16:24+00:00 2026-06-09T04:16:24+00:00

I am trying to create an iPhone app that creates a UIButton for every

  • 0

I am trying to create an iPhone app that creates a UIButton for every item in a NSArray. So basically, if there are 20 items in the array, 20 UIButtons are created, each with an identifier that somehow connects it to the respective item in the array. If I were to add another item to the array, 21 buttons would be created instead of 20. Is there a way to do this using Storyboards and Interface Builder?

Also, is there a way to paginate the UIButtons that are created? I want to have six buttons on a screen, with the option of scrolling to the next 6. So if there are 20 items in the array, it would create a ScrollView with 6 on the first 3 pages and 2 on the last one.

Thanks ahead of time! I’m trying to avoid using a TableView for this for visual reasons. If there’s an easier way to accomplish this, please let me know!

  • 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-09T04:16:25+00:00Added an answer on June 9, 2026 at 4:16 am

    In my opinion, this wouldn’t be easy using InterfaceBuilder. You better create them using code. For the pagination, you have to use a paging UIScrollView.

    #define BUTTON_WIDTH 40
    #define BUTTON_HEIGHT 30
    #define BUTTON_PADDING 10
    #define BUTTONS_PER_PAGE 6
    #define PAGE_WIDTH ((BUTTON_WIDTH + BUTTON_PADDING) * BUTTONS_PER_PAGE)
    #define MAGIC_BUTTON_TAG_OFFSET 6238 /* Maybe somebody already uses views with tags like 0, 1, 2, 3...)
    
    // in an init... method:
    
    UIScrollView *sv = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 80, 320, 320)];
    sv.contentSize = CGSizeMake(PAGE_WIDTH, sv.frame.size.height);
    sv.pagingEnabled = YES;
    [self.view addSubview:sv]; // assuming a view controller
    
    NSArray *a = [NSArray arrayWithObjects:...]; // whatever
    
    for (int i = 0; i < a.count; i++)
    {
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        btn.frame = CGRectMake(i * (BUTTON_WIDTH + BUTTON_PADDING), 0, BUTTON_WIDTH, BUTTON_HEIGHT);
        btn.tag = i + MAGIC_BUTTON_TAG_OFFSET; // to relate to the array index
        [btn setTitle:[NSString stringWithFormat:@"Button No. %d", i] forState:UIControlStateNormal];
        [btn addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
        [sv addSubview:btn];
    }
    
    - (void)buttonPressed:(UIButton *)btn
    {
        int index = btn.tag - MAGIC_BUTTON_TAG_OFFSET;
        id object = [a objectAtIndex:index];
    
        [self doSomethingWithObject:object];
    }
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to create an iphone app that does simple temperature conversion and
In an iPhone app for iOS5 I'm trying to create a controller object that
I'm trying to create an iPhone app that connects to FB using their API.
Background: I am trying to create a really simple iPhone app that will allow
Trying to create my first iPhone app that would play back audio. When I
I'm trying to create a simple iPhone app that displays a picture with a
I am trying to create an iPhone app as in the fig below: In
I'm trying to create an iOS (iPhone specific) app where users have to authenticate
I'm trying to create a normal rounded rectangular button in a new iPhone app
I'm developing an iPhone app that creates a Photo Album to hold the pictures

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.