Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

loon3y

macrumors 65816
Original poster
Oct 21, 2011
1,235
126
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



AppDelegate.h



Code:
#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;

@end



AppDelegate.m



Code:
#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];
    //brandlist.name = @"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;
}


}



@end


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


155i1kk.png




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.
 
Last edited by a moderator:

loon3y

macrumors 65816
Original poster
Oct 21, 2011
1,235
126
resolved,


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
 

loon3y

macrumors 65816
Original poster
Oct 21, 2011
1,235
126
Login Modal Screen StoryBoard Tutorials?

any suggestions, I've been really stuck at this part the past week
 

Sykte

macrumors regular
Aug 26, 2010
223
0
any suggestions, I've been really stuck at this part the past week


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.
 

loon3y

macrumors 65816
Original poster
Oct 21, 2011
1,235
126
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.
 
Last edited by a moderator:

loon3y

macrumors 65816
Original poster
Oct 21, 2011
1,235
126
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:

Code:
- (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:


Code:
- (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];   

    }
    else
    {
        // ask user to login again, 
    }
    
    
    [capturedCharacters release];
    capturedCharacters = nil;
    
    if ([elementName isEqualToString:@"str_partinfo"]) {
        // We are no longer in an item element
        inItemElement = NO;
        
    }
}
 

loon3y

macrumors 65816
Original poster
Oct 21, 2011
1,235
126
solved it using viewdidappear and a boolean
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.