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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:35:51+00:00 2026-05-23T02:35:51+00:00

I have a UIViewController called LoginViewController. The UIViewController has two UITextField, username and password.

  • 0

I have a UIViewController called LoginViewController. The UIViewController has two UITextField, username and password. This is displayed as a modalViewController when the first time the app is launched and there isn’t any credentials in the keychain. When the user clicks on the login button the keyboard that is presented is dismissed. The code is:

- (IBAction) loginClick: (UIButton *) sender
{
    if ([username isFirstResponder]){
        [username resignFirstResponder];
    }

    if ([password isFirstResponder]){
        [password resignFirstResponder];
    }

    [RKObjectManager sharedManager].client.username = username.text;
    [RKObjectManager sharedManager].client.password = password.text;
    [progressLock lock]; 
    [progressLock unlockWithCondition:0];
    [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];
    [[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"/account/verify.json" objectClass:[Login class] delegate: self];
}

Now inside the app there is an options button. When this is click it will present a modalViewController which has a logout button in it. Clicking on this logout button will present the LoginViewController again. The code is:

- (IBAction) logout:(id)sender
{
    NSUserDefaults *standardDefaults = [NSUserDefaults standardUserDefaults];
    NSString * username = [standardDefaults stringForKey:@"kApplicationUserNameKey"]; 
    NSError * error = nil;

    [standardDefaults removeObjectForKey:@"kApplicationUserNameKey"];
    [SFHFKeychainUtils deleteItemForUsername:username andServiceName:@"convore" error:&error];
    LoginViewController* lvc = [[LoginViewController alloc] init];
    lvc.delegate = self;
    [self.mgvc.groups removeAllObjects];
    [self.mgvc.table reloadData];

    Topic * topic = [Topic object];
    topic.tid = [NSNumber numberWithInt:-2];
    self.mgvc.detailViewController.topic = topic;
    self.mgvc.detailViewController.detailItem = topic.tid;

    [self presentModalViewController:lvc animated:YES];
    [lvc release];  
}

What’s weird is that I can’t seem to dismiss the keyboard when I click on the login button this time. Why is this? Is it because as of now I am displaying the LoginViewController from a modalviewcontroller? How do I solve this weird issue?

  • 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-23T02:35:52+00:00Added an answer on May 23, 2026 at 2:35 am

    I don’t know whether the fact that you can’t dismiss the keyboard is due to presenting the login in a modal view, nor do I see anything evidently wrong with your code.

    I would suggest you to change your flow and make:

    1. the logout button dismiss your first modal view and,

    2. your login view be displayed as a normal view, once the modal view disappears.

    Explicitly, you can do 2 either by one of several means:

    1. trying and pushing the login view controller on your navigation controller (if you have one);

    2. selecting it in a tab bar controller (if you use one);

    3. your modal view is shown above a view; when the modal is dismissed, that view appears again, and so the viewWillAppear selector of its view controller is called; that’s the place where you can check if you are logged in or out and show the login, if necessary; if you don’t know how to detect if your are in or out, you can always set a flag in the view controller when you dismiss the logout modal view.

      1. (after reading your comment: modal view is not full screen, so viewWillAppear is not called: you can either send viewWillAppear yourself, or send a different, custom message to your superordinate view controller so that it knows that the login view should be displayed (and possibly refresh the view).

      2. EDIT: try something like this (this requires that you call your own selector, not viewWillAppear):

        [baseNonModalViewController performSelector:@selector(yourSelector) withObject:nil afterDelay:0.0];

    Executing performSelector with a 0.0 delay, has only the effect of scheduling yourSelector for execution on the main loop. This way, first the modal will be completely dismissed, then the login view will be displayed.

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

Sidebar

Related Questions

I have a UIViewController subclass called TripViewController. This class has the following method: -
So I have a UIViewController subclass called MyTabBarViewController that has a UIScrollView. Inside of
I have a UIViewController (called AdjustViewController ) that presents another UIViewController (called SourcePickerViewController )
I have created a UIViewController class called MyViewController with a UIImageView in its XIB
I have a UIViewController with this method: -(void)prepareToShowVault { ... UINavigationController *passcodeNavigationController = [[UINavigationController
I have a UIViewController, which uses a UIScrollView and within that Scrollview it has
I have a UIViewController which is a UIWebViewDelegate and has a UIWebView inside of
I have a UIViewController that manages the display of some data. When the user
I have an application with 5 UIViewController s each inside a corresponding UINavigationController ,
I have a UINavigationController containing an UIViewController initialized with a UIView. The UINavigationController also

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.