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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:13:58+00:00 2026-06-09T13:13:58+00:00

I have three buttons with all same property other than their title. Titles are

  • 0

I have three buttons with all same property other than their title. Titles are ‘A’, ‘B’ and ‘C’ respectively. I wrote a method where I have written all common properties of these three buttons and calling this method where I want to add those buttons on view. I have done all theses, but struct at button Title. I used for loop to add theses buttons to view.
Here is my code:

This is method with all common properties of three buttons.

-(UIButton *)setMiddlePlayButton{
    UIButton * middleButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [middleButton setBackgroundImage:[UIImage imageNamed:@"Middle"] forState:UIControlStateNormal];
    [middleButton addTarget:self action:@selector(playButtonPressed:)
           forControlEvents:UIControlEventTouchDown];
    middleButton.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
    return middleButton;
}

Calling the method in this way to add buttons on the view.

for(int i= 0; i<3; i++){
        UIButton * middleButtons = [self setMiddlePlayButton];
        middleButtons.tag= 2+i;
        //Here I have to add button Title which is 'A' for first button with tag 2, 'B' for second button with tag 3 and 'C' for third button. 
        [self.view addSubView:middleButtons];

    }

I am not finding a way to get the title, is anything possible with ASCII value? Or is there any other way to do this? Please help.

  • 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-09T13:13:59+00:00Added an answer on June 9, 2026 at 1:13 pm

    Try this code

    for(int i= 0; i<3; i++){
        UIButton * middleButtons = [self setMiddlePlayButton];
        middleButtons.tag= 2+i;
        [middleButtons setTitle:[NSString stringWithFormat:@"%c", 65+i] forState:UIControlStateNormal];
        [self.view addSubview:middleButtons];   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three radio buttons with same name and different values.When I click the
I have 4 buttons, all of them have the same width. <s:Button id=btn1 width={btnWidth}
I have three buttons in a three column structure in a custom cell in
In my page I have three radio buttons and I want to checked the
I have div which has three buttons as, <div id=buttons> <input id=preview class=ButtonStyle type=submit
I have one label field and three buttons with the name of red, yellow,
I have a group of three radio buttons. Depending on which radio button is
Lets say I have one row with three columns - some buttons on left
I currently have a couple different user controls that provide the same functionality: three
I have a screen where multiple Buttons use the same background Drawable. I have

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.