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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:44:05+00:00 2026-05-22T22:44:05+00:00

here i have this code that i’m trying where openingHoursView.ohLocation has two values value1

  • 0

here i have this code that i’m trying where
openingHoursView.ohLocation has two values “value1” and “value2“.
So does openingHoursView.idNum with values “id1” and “id2“.
When i execute my code I only get one button with the name of “value2” and “id2“. So my question would be how to create all the buttons for the values of openingHoursView.ohLocation and openingHoursView.idNum

- (void)loadView {

    storeAppDelegate = (StoreAppDelegate *)[[UIApplication sharedApplication] delegate];    

    int row = [storeAppDelegate.openingHoursLocationsDelegate count]-1;
    for (int i = 0; i <= row; i++) {
        openingHoursView = [storeAppDelegate.openingHoursLocationsDelegate objectAtIndex:i];

        self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];

        self.view.backgroundColor = [UIColor whiteColor];

        //create the button
        UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        //set the position of the button
        if (i%2 != 0) {
            button.frame = CGRectMake(30 , 100 , 150, 30);

        }else {
            button.frame = CGRectMake(30 , 100 + i*50, 150, 30);
        }


        //set the button's title
        [button setTitle:openingHoursView.ohLocation forState:UIControlStateNormal];

        //listen for clicks
        [button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
        button.tag = [openingHoursView.idNum intValue];
        //add the button to the view
        [self.view addSubview:button];
    }
}

-(IBAction) buttonPressed: (id) sender {
    UIButton* button = (UIButton*)sender;

    NSLog(@"User clicked %d", button.tag);
    // Do something here with the variable 'sender'
}

Just an explanation objectAtIndex:0 for openingHoursView.ohLocation is “value1” and for objectAtIndex:1 is “value2“. Same procedure for openingHoursView.idNum

  • 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-05-22T22:44:05+00:00Added an answer on May 22, 2026 at 10:44 pm

    The problem is that you’re doing:

    self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    
    self.view.backgroundColor = [UIColor whiteColor];
    

    inside the for loop and thus gets overwritten on each iteration. You should only do it once before the for loop.

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

Sidebar

Related Questions

I have this code here that has two arrays. It sorts arr[] , so
See here: http://code.google.com/p/ie7-js/ Does anyone have any experience or remarks about this javascript? Is
I have this code that I found online that does an infinite rotating gallery,
I have this code here that creates a Tkinter Canvas widget, then embeds an
I have this jquery code that handles the logic of placeholder text for two
I have some problems with this code? Here is my code that creates text
here's my problem. I have this piece of code that sets the user location
I have this piece of code that has a problem. so can you help
Suppose I have this code executed by two different threads T1 and T2 that
I have this code here: var infiltrationResult; while(thisOption) { var trNode = document.createElement('tr'); var

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.