2017-07-19 1 views
0

J'ai créé simple maître application détaillée pour login.I supprimé le MasterViewController, DetailViewController et Main.storyboard selon ce tutoriel:fonction AppDelegate ne se charge pas vue Tableau de commande

Login app to mysql DB [part 1]

En fonction AppDelegate didFinishLaunchingWithOptions i fait le changement suivant

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    // Override point for customization after application launch. 

    self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds] ]; 

    /*UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController; 
    UINavigationController *navigationController = [splitViewController.viewControllers lastObject]; 
    navigationController.topViewController.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem;*/ 

    LoginTableViewController *loginTableViewController=[[LoginTableViewController alloc]initWithNibName:@"LoginTableViewController" bundle:nil ]; 

    self.navigationController =[[UINavigationController alloc]initWithRootViewController:loginTableViewController]; 

    self.window.rootViewController=self.navigationController; 
    [self.window makeKeyWindow]; 

    return YES; 
} 

Je commentais cette fonction de la fonction App délégué

/* 
    - (BOOL)splitViewController:(UISplitViewController *)splitViewController collapseSecondaryViewController:(UIViewController *)secondaryViewController ontoPrimaryViewController:(UIViewController *)primaryViewController { 
............................. 

    }*/ 

J'ai créé LoginTableTableViewController avec xib de la sous-classe UITableViewController. J'ai créé LoginTableTableViewController.h

#import "LoginTableViewController.h" 

@interface LoginTableViewController() 

@end 

@implementation LoginTableViewController 
@synthesize arraylogin,userNameTextField,passwordTextField; 
bool isKeyboardVisible=FALSE; 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    arraylogin=[[NSArray alloc] initWithObjects:@"user name",@"password",nil]; 
    //set title 
    [email protected]"Best App"; 

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardAppeared) name:UIKeyboardDidShowNotification object:nil]; 

    // Uncomment the following line to preserve selection between presentations. 
    // self.clearsSelectionOnViewWillAppear = NO; 

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 
    // self.navigationItem.rightBarButtonItem = self.editButtonItem; 
} 

-(void) loginAction 
{ 
    if([userNameTextField.text isEqualToString:@""] || [passwordTextField.text isEqualToString:@""]) 
    { 

     // UIAlertView @alert=[[UIAlertView alloc] intitWithTitle:@"alert" messge:@"Please fill in all //the fields" delegate:self cancel] 
     UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"alert" message:@"Please fill in all the fields" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; 
     [alert show]; 
     //i will use a code to connect to DB turorial 

    } 
} 
- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 
-(void)keyboardAppeared 
{ 
    if(isKeyboardVisible==false) 
    { 
     isKeyboardVisible=true; 

     UIBarButtonItem *btnGo=[[UIBarButtonItem alloc] initWithTitle:@"Go" style:UIBarButtonItemStyleBordered target:self action:@selector(loginAction)]; 
     self.navigationItem.rightBarButtonItem=btnGo; 
    } 
} 
#pragma mark - Table view data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
#warning Incomplete implementation, return the number of sections 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
#warning Incomplete implementation, return the number of rows 

    return [arraylogin count]; 
} 


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *[email protected]"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifer]; 

    if (cell==nil) 
    { 
     cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifer]; 

    } 
    //cell are not selectable 
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; 
    CGRect frame; 
    frame.origin.x=10; 
    frame.origin.y=10; 
    frame.size.height=30 ; 
    frame.size.width= 200; 

    UILabel *label=[[UILabel alloc]initWithFrame:frame]; 

    label.font=[UIFont boldSystemFontOfSize:16.0]; 
    label.text=[arraylogin objectAtIndex:indexPath.row]; 
    [cell.contentView addSubview:label]; 

    frame.origin.x=110; 
    frame.size.height=90 ; 
    frame.size.width= 180; 

    // Configure the cell 
    if(indexPath.row==0) 
    {//username part 
     userNameTextField=[[UITextField alloc] initWithFrame:frame]; 

     userNameTextField.returnKeyType=UIReturnKeyDefault; 
     [cell.contentView addSubview:userNameTextField]; 
    } 
    else{//password part 
     passwordTextField=[[UITextField alloc] initWithFrame:frame]; 
     passwordTextField.returnKeyType=UIReturnKeyDefault; 
     passwordTextField.secureTextEntry=YES; 
     [cell.contentView addSubview:passwordTextField]; 
    } 
    return cell; 
} 


/* 
// Override to support conditional editing of the table view. 
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { 
// Return NO if you do not want the specified item to be editable. 
return YES; 
} 
*/ 

/* 
// Override to support editing the table view. 
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 
if (editingStyle == UITableViewCellEditingStyleDelete) { 
// Delete the row from the data source 
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; 
} else if (editingStyle == UITableViewCellEditingStyleInsert) { 
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 
} 
} 
*/ 

/* 
// Override to support rearranging the table view. 
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { 
} 
*/ 

/* 
// Override to support conditional rearranging of the table view. 
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { 
// Return NO if you do not want the item to be re-orderable. 
return YES; 
} 
* 
/

/* 
#pragma mark - Table view delegate 

// In a xib-based application, navigation from a table can be handled in -tableView:didSelectRowAtIndexPath: 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
// Navigation logic may go here, for example: 
// Create the next view controller. 
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:<#@"Nib name"#> bundle:nil]; 

// Pass the selected object to the new view controller. 

// Push the view controller. 
[self.navigationController pushViewController:detailViewController animated:YES]; 
} 
*/ 
-(void) viewDidUnload 
{ 
    [super viewDidUnload]; 
    self.arraylogin=nil; 
    self.userNameTextField=nil; 
    self.passwordTextField=nil; 
} 
/* 
#pragma mark - Navigation 

// In a storyboard-based application, you will often want to do a little preparation before navigation 
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
// Get the new view controller using [segue destinationViewController]. 
// Pass the selected object to the new view controller. 
} 
*/ 

@end 

Ce programme devrait être en cours d'exécution et de montrer dehors comme dans cette image

enter image description here.

L'exécution arrête le programme sur certains threads de la classe principale comment je peux supprimer cette erreur et obtenir la sortie requise? Vous pouvez télécharger l'exemple de code de ce lien pour la correction. https://drive.google.com/file/d/0B5pNDpbvZ8SnV3Zab3VPM1B0a0k/view?usp=sharing

+0

Accédez à BreakPoint Navigator, ajoutez un" point d'arrêt d'exception ", exécutez le projet et vous obtiendrez des informations plus utiles sur l'erreur. –

+0

J'ai déjà couru le projet en ajoutant un "breakpoint d'exception" et la navigation de point de rupture. L'information utile est exécutée par le programme appdelegate fonction mais quand atteint la classe de la fonction principale son exécution threading stoping .so l'application doesnot exécute le LoginTableViewController.h –

Répondre

1

Votre projet spécifie toujours qu'un storyboard "principal" doit être chargé. Modifiez votre fichier Info.plist pour supprimer l'entrée du storyboard et vous obtiendrez l'erreur actuelle. (Si vous incluez des messages d'erreur provenant de votre console de débogage lorsque vous posez une question, cela facilite la tâche à tous ceux qui tentent de vous aider, par exemple: "Terminaison de l'application due à une exception non interceptée 'NSInvalidArgumentException', raison: 'Impossible de trouver un storyboard nommé 'Main' dans le lot ".)

+0

J'ai supprimé le storyboard "Main" de info.plist. Il ne fonctionne pas. –

+0

Quel genre de "ne fonctionne pas" obtenez-vous maintenant? –