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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:25:36+00:00 2026-05-20T11:25:36+00:00

I have the following code: [self.view bringSubviewToFront:loggingIn]; [self loginWithUsername:user Password:pw]; This is inside an

  • 0

I have the following code:

    [self.view bringSubviewToFront:loggingIn];
    [self loginWithUsername:user Password:pw];

This is inside an IBAction method for a button press. The button stays highlighted until the user is logged in (this could take several seconds) and THEN the view appears. How come the view isn’t appearing before the login method is called?

  • 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-20T11:25:37+00:00Added an answer on May 20, 2026 at 11:25 am

    John’s answer would work, but it has to do with the Run Loop than blocking threads. Basically, whenever your app receives an event such as a button getting clicked, your handler gets run in the main thread. Any changes you make to the UI happen after your handler finishes. This lets Cocoa optimize the graphics updates by analyzing/performing them together.

    Run Loop:
      Event -> Your Handler Code -> System Updates UI
    

    So you need to let your handler code finish in order to let the system start updating the UI – before invoking your loginWithUsername:Password: [sic] method. Scheduling a timer will bump it to the next iteration of the run loop (the timer going off becomes the “event” that triggers the next loop). So,

    Run Loop (2 iterations):
      Mouse Click -> Your Handler Code (reorder views) -> System reorders views
      Timer Fires -> Your Handler Code (trigger login) -> Any addl UI updates
    

    So do something like this:

    - (void) buttonHandler: (id)sender {
        [self.view bringSubviewToFront:loggingIn];
        [self performSelector: @selector(performLogin)
                   withObject: [NSArray arrayWithObjects:user, pw, nil]
                   afterDelay: 0];
    }
    
    - (void) performLogin: (NSArray *)args {
        [self loginWithUsername:[args objectAtIndex:0] Password:[args objectAtIndex:1]];
    }
    

    It doesn’t have to be an array. You could also pack your username and password in a dictionary and use that as your argument instead.

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

Sidebar

Related Questions

I have the following code: -(void)textFieldDidBeginEditing:(UITextField *)textField { CGRect textFieldRect = [self.view.window convertRect:textField.bounds fromView:textField];
I have the following code in my viewWillAppear: - (void) viewWillAppear:(BOOL)animated{ self.view.backgroundColor = [UIColor
I have the following dispatch_async code: dispatch_async(openGLESContextQueue, ^{ [(EAGLView *)self.view setFramebuffer]; // Replace the
I have following code in my application. [self.navigationController pushViewController:x animated:YES]; It will push a
i have the following code def get(self): date = datetime.date.today() loc_query = Location.all() last_cursor
I have the following code: #!/usr/bin/ruby class Person def self.speak p = self.new puts
I have the following code: NSLog(@items: %d, [items count]); NSLog(@allObjects: %d, [self.allObjects count]); [self.allObjects
I have the following code: class MyClass module MyModule class << self attr_accessor :first_name
If I have the following piece of Ruby code: class Blah def self.bleh @blih
I have following code class User attr_accessor :name end u = User.new u.name =

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.