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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:41:31+00:00 2026-05-26T18:41:31+00:00

Hi All I’m new to iOS development and am currently having an issue with

  • 0

Hi All I’m new to iOS development and am currently having an issue with something, I’m trying to make a login form appear modally if a user is not logged in.

I’m using NSUserDefaults to store an id which I’m simply checking if it exists. If it doesnt then I would want the UIViewController to appear.

So far I have the following code in my UINavigationController which is within a UITabViewController , I’m trying to get the UIViewController to appear above the First UINavigationController (the one that is selected), at the moment the animation is happening but there is only a black screen even though the Login screen has all the relevant text boxes etc already created. If I set this Login screen as the initial view to load, it loads up fine.

This is the code that appears in the First viewcontroller of the UINavigationController.

 NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
if (![prefs stringForKey:@"id"]){
    LoginViewController *loginController = [[LoginViewController alloc] init];
    [self presentModalViewController:loginController animated:YES];
} else {
    [self loadCoffeeUserOrders:[prefs stringForKey:@"id"]];  
}

the modal view is loading up but at the moment it just appears black, I’ve tried creating a new Login Screen and the same thing happens: nothing but a black screen.

hope there is enough information there for someone to understand what might be going on, I am very new to iOS development so if I’ve made some mistakes it would be nice to know where I’m going wrong.

thanks

  • 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-26T18:41:31+00:00Added an answer on May 26, 2026 at 6:41 pm

    So, the LoginViewController you are creating here is a different instance from the one that you set up in your storyboard. I think what you want to cause the one in the storyboard to be loaded and presented.

    The easiest way is to create a segue in the storyboard from your first view controller to the login view controller that you created there. You can ctrl-drag from one view controller to the other and select “Modal” as the type of segue. Then go to the inspector for that segue and give it an identifier. Let’s say you call it “segueToLogin”.

    Then to perform that segue from your code just do something like this:

      if (![prefs stringForKey:@"id"]){
    
        [self performSegueWithIdentifier:@"segueToLogin" sender:self];
    
      }
    

    Hope that helps.

    EDIT

    So just to answer your question, imagine this:

    You have this great idea for an app, so you take a sheet of paper off your pad and you sketch out this great design. Then your colleagues come by so you rip off a new blank sheet of paper and show them that instead. They won’t be impressed.

    Same thing happened here. You set up a view controller in your storyboard with all your views. But then when it came time to show it, you pulled out a new totally blank view controller and showed that to the user instead. By pulling and actuating the segue instead, you end up loading the actual view controller instance you wanted.

    Now on segues, you create those in the storyboard to allow the user to navigate through the scenes. Sometimes those segues are directly attached to a button or something. But in this case you don’t want to ask the user to press a button or something to present the login vc, so you are performing the segue yourself.

    Hope that makes sense.

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

Sidebar

Related Questions

All, I'm trying to use the jQuery Form Validator (http://docs.jquery.com/Plugins/Validation). However I'd like to
All I want is to make a simple user password login. I have put
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
All, I am trying to create a table to receive user inputs (UGC). This
I want use html5's new tag to play a wav file (currently only supported
All I want to do is make the last three columns of my grid
All right, so I've got an applet I'm trying to embed into an HTML
all. My question is in regards to a problem I'm encountering when trying to
all I am trying to figure out how to set a checkbox to a
All, I have the following class so to check to see if the form

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.