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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:35:24+00:00 2026-06-07T04:35:24+00:00

I am adding 20 UIButton programmatically in UIVIew, what I have to do is

  • 0

I am adding 20 UIButton programmatically in UIVIew, what I have to do is add animation on these buttons such that first button appear at time ‘t’ after that second will appear at time time ‘t+1’ and so on. I have tried adding buttons after some delay but its not working all the buttons will be showed to view at a time.
If there is solution to do this please let me know.

for(int i = 0; i<20;i++)
{
    UIButton *button = [UIButton buttonWithType: UIButtonTypeCustom]; 
    [button setBackgroundImage:[UIImage imageNamed:@"i_setting30.png"] forState:UIControlStateNormal];  
    [button setImage:[UIImage imageNamed:@"threadmenu.png"] forState:UIControlStateNormal];
    [button addTarget: self action:@selector(threadmenu) forControlEvents:UIControlEventTouchUpInside]; 
    [self.view performSelector:@selector(addSubview:) withObject:button afterDelay:1];
    button.frame = CGRectMake(0+i*20, 0, 20, 20);
}
  • 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-07T04:35:26+00:00Added an answer on June 7, 2026 at 4:35 am

    You can use NSTimer to implement this.

    You can schedule a timer that will call the desired method after every ‘t’ time until all 20 buttons has been added on the view.

    NSTimer* timer = [NSTimer scheduledTimerWithTimeInterval:t target:self selector:@selector(addButton:) userInfo:nil repeats:YES];
    
    (void) addButton:(NSTimer*)timer{
       //Your code for adding button goes here 
       buttonCount++;
       if(buttonCount==20)
       {
              [timer invalidate];
              timer = nil;
              buttonCount = 0;
       }
    }
    

    Here ‘buttonCount‘ is an integer variable that will keep the track of number of buttons added to the view. You can declare it in your header file.

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

Sidebar

Related Questions

Suppose I have a button that I am adding to an annotation object in
I would like to add some buttons on CPLayerHostingView. I have tried the same
Basically I have a custom UIButton and this custom button contains subviews. If I
I'm trying to add a UIButton to a UIView, but am having some trouble
I'm creating and adding an UIButton dynamically to UIView, like: UIButton *btn = [UIButton
I have a UIButton, and I'm adding an image to it using this code:
I am having a trouble adding left padding on a UIButton . I have
I have a question regarding best practices when adding targets to a UIButton on
I am adding the following codes to add a footer with a button to
i have a table view. And im adding two buttons to each cell: -

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.