Please Help! StoryBoard Login!

Discussion in 'iPhone/iPad Programming' started by loon3y, Mar 5, 2012.

  1. loon3y, Mar 5, 2012
    Last edited by a moderator: Mar 5, 2012

    macrumors 6502a

    Oct 21, 2011
    I'm literally having so much trouble with just having the loginview show up using a modal view thats called when the app starts. my app used the tab bar template in the beginning.

    please can someone tell me what I'm doing wrong


    #import <UIKit/UIKit.h>
    #import "AppDelegateProtocol.h"
    #import "DetailsViewController.h"
    #import "GlobalStrings.h"
    @class GlobalStrings;
    @interface AppDelegate : UIViewController
    <UIApplicationDelegate, AppDelegateProtocol>
        GlobalStrings* theGlobalClass;
        IBOutlet DetailsViewController* theDetailsViewController;
       //UIViewController *loginViewController;
    @property (strong, nonatomic) UIWindow *window;
    @property (nonatomic, retain) GlobalStrings *theGlobalClass;
    @property (nonatomic, retain) IBOutlet DetailsViewController *theDetailsViewController;
    //@property (nonatomic, retain) UIViewController *loginViewController;


    #import "AppDelegate.h"
    #import "InventoryViewController.h"
    #import "SalesViewController.h"
    #import "AppDelegateProtocol.h"
    #import "GlobalStrings.h"
    #import "Brand.h"
    #import "StoreViewController.h"
    #import "LoginViewController.h"
    @implementation AppDelegate
        NSMutableArray *brandLists;
    @synthesize window = _window;
    @synthesize theGlobalClass, theDetailsViewController;
    - (void)dealloc
        [_window release];
        self.theGlobalClass = nil;
        self.theDetailsViewController = nil;
        [super dealloc];
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
        brandLists = [NSMutableArray arrayWithCapacity:20];
        Brand *brandlist = [[Brand alloc] init];
        // = @"DeWalt";
        brandlist.rating = 1;
        [brandLists addObject:brandlist];
    //    LoginViewController *sampleView = [[[LoginViewController alloc] init] autorelease];
    //    [self presentModalViewController:sampleView animated:YES];
      UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];    LoginViewController *loginViewController = [storyboard instantiateViewControllerWithIdentifier:@"loginViewController"];
               [self presentModalViewController:loginViewController animated:YES];
      // [self presentViewController: loginViewController animated:  YES completion: nil];
        return YES;

    here is how i linked it, which i feel like is terribly wrong.


    it crashes every time, I've tried tons of other methods, from other examples and tutorials.

    I've been on this problem for about 2 days, if anyone can help ill be very thankful.
  2. thread starter macrumors 6502a

    Oct 21, 2011

    wow so simple, i don't know why this isn't out in the internet more.

    all you had to do is go into IB and set the login view as the initial controller.

    no coding needed except in your loginview nib
  3. thread starter macrumors 6502a

    Oct 21, 2011
    Login Modal Screen StoryBoard Tutorials?

    any suggestions, I've been really stuck at this part the past week
  4. macrumors regular

    Aug 26, 2010

    What are you stuck on? In your storyboard create the root view then create your login view, don't forget to change the segue to modal. Then force the segue to load the login view.
  5. loon3y, Mar 8, 2012
    Last edited by a moderator: Mar 8, 2012

    thread starter macrumors 6502a

    Oct 21, 2011
    i was mistaken.

    i used storyboard mode, so i ctrl drag clicked a login button (i had for testing) in my first view controller to show the modal view.

    and my login function in my login view controller (after successfully getting "Y (yes)") and cancel button (self dismiss modal view) only worked if i came to the loggin view controller via first view controller.

    i tried to vice versa, i than i ctrl dragged my login button to the first view controller, which just dismissed my loginview regardless.

    than i tried making my login view the initial view controller, without making a link in storyboard and of course, nothing happens.

    my login functions work, its just presenting it, and most storyboard loginview and modal view examples use navigation controllers in their code.

    i made from a tab bar, now I'm currently starting a new project form a master detail template, and see if it works out there considering all the example coding used navigation controller.

    my other idea was to make a 2nd window, and have it appear and than dismiss it somehow, but i felt like that was kind of way out.
  6. thread starter macrumors 6502a

    Oct 21, 2011
    ok, i present my modal new in the viewdidappear in my 1st view controller, but now once i successfully login right when i get back to my 1st view controller, it goes right back to the login screen, what the heck is happening?

    1st view controller:

    - (void)viewDidAppear:(BOOL)animated
        [super viewDidAppear:animated];
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
        [vc setModalPresentationStyle:UIModalPresentationFullScreen];
        [self presentModalViewController:vc animated:YES];

    login view controller:

    - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName 
      namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName 
        NSMutableString *Yes =[[NSMutableString alloc] initWithString:@"Y"];
        if ([ capturedCharacters isEqualToString:Yes])
            [self dismissModalViewControllerAnimated:YES];   
            // ask user to login again, 
        [capturedCharacters release];
        capturedCharacters = nil;
        if ([elementName isEqualToString:@"str_partinfo"]) {
            // We are no longer in an item element
            inItemElement = NO;
  7. thread starter macrumors 6502a

    Oct 21, 2011
    solved it using viewdidappear and a boolean

Share This Page