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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:21:39+00:00 2026-05-28T00:21:39+00:00

I have created an app which starts with a login page, after entering some

  • 0

I have created an app which starts with a login page, after entering some user information I send a GET to server. Using the response values I create buttons, their title etc dynamically. Everything is ok, but after I send GET and use the JSON response my buttons are being created on the same view with the login page. I want to also create a new view and create buttons on that view. Since I use some parameters from user information I need to create the view in the same class with my MainViewController (in my case it is BNT_1ViewController) but I can’t figure out how to handle this situation. I’m sharing the code too, maybe it helps.
And a second question, with this code my buttons just move downwards but I want two lines of buttons. How can I change the position of a button in the x axis? I changed those values but the whole column changes, even though I want just to place two buttons in the same line, all the struct replaces..

   -(IBAction)Accept:(id)sender
    {   userName=[[NSString alloc] initWithString:userNameField.text ];
        [userNameField setText:userName];
        NSUserDefaults *userNameDef= [NSUserDefaults standardUserDefaults];
        [userNameDef setObject:userName forKey:@"userNameKey"];
        password =[[NSString alloc] initWithString:passwordField.text];
        [passwordField setText:password];
        NSUserDefaults *passDef=[NSUserDefaults standardUserDefaults];
        [passDef setObject:password forKey:@"passwordKey"];
       serverIP=[[NSString alloc] initWithString: serverField.text];
        [serverField setText:serverIP];
        NSUserDefaults *serverDef=[NSUserDefaults standardUserDefaults];
        [serverDef setObject:serverIP forKey:@"serverIPKey"];
        [userNameDef synchronize];
        [serverDef synchronize];
        [passDef synchronize];
        UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"BNTPRO "
                                                          message:@"Your User Informations are going to be sent to server. Do you accept?"
                                                         delegate:self
                                                cancelButtonTitle:@"OK"
                                                otherButtonTitles:@"Cancel",  nil];
        [message show];
        }
 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    {


     NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
         if([title isEqualToString:@"OK"])
        {
             if([userNameField.text isEqualToString:@"" ]|| [passwordField.text isEqualToString:@""] || [serverField.text length]<10) 
            {
                UIAlertView *message1 = [[UIAlertView alloc] initWithTitle:@"BNTPRO "
                                                                   message:@"Your User Informations are not defined properly!"
                                                                  delegate:nil
                                                         cancelButtonTitle:@"OK"
                                                         otherButtonTitles:  nil];
                [message1 show];
                [userNameField  resignFirstResponder];
                [passwordField resignFirstResponder];
                            return;
            }
            //## GET code to here**
            NSString *str1=[@"?username=" stringByAppendingString:userNameField.text];
            NSString *str2=[@"&password=" stringByAppendingString:passwordField.text];
            NSString *str3=[str1 stringByAppendingString:str2];
            NSString *str4 =[@"http://" stringByAppendingString:serverField.text];
      NSURL *url=[NSURL URLWithString:[str4 stringByAppendingString:[@"/ipad/login.php" stringByAppendingString:str3]]];
        NSLog(@"%@\n",url);
        //get the url to jsondata
        NSData *jSonData=[NSData dataWithContentsOfURL:url];

        if (jSonData!=nil) {
            NSError *error=nil;
            id result=[NSJSONSerialization JSONObjectWithData:jSonData options:
                       NSJSONReadingMutableContainers error:&error];
            if (error==nil) {
               NSDictionary *mess=[result objectForKey:@"message"];
                NSDictionary *messContent=[mess valueForKeyPath:@"message"];
                NSDictionary *messDate=[mess valueForKeyPath:@"date"];
                NSDictionary *messID=[mess valueForKeyPath:@"ID"];
                NSLog(@"%@ *** Message %@ \n Message Content: %@ \n Mesage ID: %@ \n Message Date: %@", result, mess, messContent, messID,messDate);
                NSString*key1=[ result objectForKey:@"key" ];
                NSString *s1=[@"http://" stringByAppendingString:serverField.text];
                NSString *s2=[s1 stringByAppendingString:@"/ipad/button.php"];
                NSURL *url2=[NSURL URLWithString:[s2 stringByAppendingString:[@"?key=" stringByAppendingString:key1]]];
                NSLog(@"\n%@\n",url2 );
                NSData *data2=[NSData dataWithContentsOfURL:url2];
                id result2=[NSJSONSerialization JSONObjectWithData:data2 options:NSJSONReadingMutableContainers error:nil];

                //i create buttons from here
                 self.buttons = [NSMutableArray array];
                CGFloat yPosition = 43.0f;//measure from top point
                CGFloat xPosition = 34.0f;
                const CGFloat buttonHeight = 70.0f;//height
                 const CGFloat buttonMargin = 32.0f;//distance between two buttons

                for(NSDictionary* buttonData in result2) {

                    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
                NSString* buttonTitle = [buttonData objectForKey:@"name"];
          [button addTarget:self action:@selector(secondAct:) forControlEvents:UIControlEventTouchUpInside];
                 [button setBackgroundColor:[UIColor cyanColor]];

                [button setTitle:buttonTitle forState:UIControlStateNormal];

              //      button.frame = CGRectMake(20.0f, yPosition, 130.0f, buttonHeight);//if([count]%2==1)
                     NSLog(@"Ne oluyor?= %d",[buttonData count]);

                 button.frame = CGRectMake(170.0f, yPosition, 130.0f, buttonHeight);//if([count]%2==1)



                [button addTarget:self action:@selector(secondAct:)                   forControlEvents:UIControlEventTouchUpInside];
                [self.view addSubview:button];
                [self.buttons addObject:button];
                yPosition+= buttonHeight + buttonMargin;
    }        }
}
else if([title isEqualToString:@"Cancel"])
{
    NSLog(@"You changed your mind!");
}
}
  • 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-28T00:21:40+00:00Added an answer on May 28, 2026 at 12:21 am

    following are answers of your queries, might be it will help you-
    1. I want to also be creating a new view and create buttons on that view.
    for this you can create a new view controller and push that view controller once you received the response. Also you can float the response from one controller to other.
    2. And a second question, with this code my buttons just move downwards but i want two lines of buttons
    You need to set frames of buttons properly, then will work perfectly.

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

Sidebar

Related Questions

I have created an app that sends intents among multiple activities. After doing some
I have created an app which allows users to buy non-consumable content. The retrieving-ids-payment-process
I have created an app which allows users to buy non-consumable content. The retrieving-ids-payment-process
I have created an app in which I have used achartengine to construct the
I've created an app which contains form and that have to filled up in
I have created an app that uses NSTimer, which gets triggered each second. My
I have created a library which reads the app.config file and gets the type
I have a FB App which I created using Fandjango. It works fine if
I have created an animated game app, In which I am using NSTimer to
I have created a database for my android app which contains static data and

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.