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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:16:13+00:00 2026-06-14T00:16:13+00:00

I want to create a grid view of buttons which will be created dynamically

  • 0

I want to create a grid view of buttons which will be created dynamically .and on click of button in grid view different task for every button.how can i do this any help will be appreciate?

  • 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-14T00:16:15+00:00Added an answer on June 14, 2026 at 12:16 am

    I have done This Before Using Scroll View This May help you.

           int number_of_types = 20; // (no of total buttons )
    
    
    int btncount=0;
            int number_of_buttons_in_row = 4;
            CGFloat screen_width = 280.0, button_width = 70;
    
            CGFloat xpadd = (screen_width - ( number_of_buttons_in_row * button_width ))/(number_of_buttons_in_row+1);
    
            CGFloat x_coord, y_ccord;
            int buttonXOffset, buttonYOffset, buttonWidth, buttonHeight;
            buttonWidth = 57;
            buttonHeight = 57;
    
            x_coord = 20;
            y_ccord = 70;
    
            int number_of_rows;
    
            if((number_of_types % number_of_buttons_in_row) == 0)
                number_of_rows = number_of_types / number_of_buttons_in_row;
            else 
                number_of_rows = number_of_types / number_of_buttons_in_row + 1;
    
            int number_of_buttons_count = 0;
            for (UIView * view in scrollBack.subviews) {
                if(view.tag!=999 )
                {   
                    [view removeFromSuperview];
                    view = nil;
                }
            }
    
            for (int i = 0; i< number_of_rows; i++) {
                for (int j=0; j<number_of_buttons_in_row; j++) {
    
                    buttonXOffset = 75;
                    buttonYOffset = 58;
                    UIButton *btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
                    btn.frame = CGRectMake(40, 0, 57, 57);
    
                    x_coord += button_width/2 + xpadd;
                    btn.center = CGPointMake(x_coord, y_ccord);
    
                    [scrollBack addSubview:btn];
    
                    buttonXOffset = x_coord - buttonWidth/2;
                    buttonYOffset = y_ccord - buttonHeight/2;
    
    
                    UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(buttonXOffset, buttonYOffset + buttonHeight + 4, buttonWidth+7, 28)];
    
    
    
                    btn.tag= btncount;
    
                    [btn setTitle:@"your Title "];
    //if titles are in a Array  then you can Use 
    
        [btn setTitle:[titleArray objectatindex:btncount] forState:UIControlStateNormal];
    
    
                    [btn addTarget:self action:@selector(yourFunction:) forControlEvents:UIControlEventTouchUpInside];
    
                    label.text = [titleArray objectatindex:btncount];
    
    
    
    
    
    
                    label.tag = 777;
                    label.backgroundColor = [UIColor clearColor];
                    label.font=[UIFont fontWithName:@"Helvetica" size:11];
                    label.font=[UIFont boldSystemFontOfSize:11];
                    label.textAlignment = UITextAlignmentCenter;
                    label.numberOfLines = 0;
    
                    [scrollBack addSubview:label];
                    [label release];
    
                    x_coord += button_width/2;
                    number_of_buttons_count++;
                    if(number_of_buttons_count == 20)
                        break;
    
                    btncount++;
    
                }
                if(number_of_buttons_count == 20)
                    break;
                y_ccord += 120;
                x_coord = 20;
    
    
    
            }
            scrollBack.contentSize = CGSizeMake(320, buttonYOffset + 200);
    
    
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want create an application with animate button? how can i do? after click
I want to create a property grid (the one which is similar to the
i am having an custom alert view which pop ups on a button click
I created an gridview it has favorite button and I want to change the
I want to create a resizable grid, filled with draggable and sortable icons (similar
I want create wordpress website into which I want create user management... That means
I want to use the System.Windows.Controls.DocumentViewer to view a FixedDocument I created from a
I created a View extend Ext.grid.Panel and also attach a tbar to it, in
I have a gridview button that I programmatically created and I want to load
I want to provide custom paging in grid view. <asp:GridView ID=gvFirst runat=server AutoGenerateColumns=false AllowPaging=true

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.