Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have to say that I am a beginner in iOS development bit I think I can help you.</p> <p>In you Storyboard make a TabBarController and all the other UIViewController's. Link them to the TabBarController and add assign classes to them. In your case one of the UIViewController will be called LoginViewController.Now when your app starts the LoginViewController must be the first tab an you simply add this code to disable the tabs:</p> <pre><code>[[[[self.tabBarController tabBar]items]objectAtIndex:1]setEnabled:FALSE]; [[[[self.tabBarController tabBar]items]objectAtIndex:2]setEnabled:FALSE]; [[[[self.tabBarController tabBar]items]objectAtIndex:3]setEnabled:FALSE]; </code></pre> <p>And again you can enable them with:</p> <pre><code>[[[[self.tabBarController tabBar]items]objectAtIndex:1]setEnabled:TRUE]; [[[[self.tabBarController tabBar]items]objectAtIndex:2]setEnabled:TRUE]; [[[[self.tabBarController tabBar]items]objectAtIndex:3]setEnabled:TRUE]; </code></pre> <p>So your LoginAction function would look like this:</p> <pre><code>- (void) LoginAction { AppDelegate *passData = (AppDelegate *)[[UIApplication sharedApplication] delegate]; if ([CustomerUsername.text isEqualToString:@""] || [CustomerPassword.text isEqualToString:@""]) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"alert" message:@"Please Fill all the field" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; return; } // i will use a code from connect to DB tutorial NSString *strURL = [NSString stringWithFormat:@"http://localhost:8888/Staff.php?userName=%@&amp;password=%@",CustomerUsername.text, CustomerPassword.text]; // to execute php code NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]]; // to receive the returend value NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding]; if ([strResult isEqualToString:@"1"]) { //MainTabViewController *main = [[MainTabViewController alloc] initWithNibName:nil bundle:nil]; //UITabBarItem *tabBarItem = [[main.MainTabBar items] objectAtIndex:1]; //[tabBarItem setEnabled:TRUE]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Success" message:@"You are now Logged In" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; [[[[self.tabBarController tabBar]items]objectAtIndex:1]setEnabled:TRUE]; [[[[self.tabBarController tabBar]items]objectAtIndex:2]setEnabled:TRUE]; [[[[self.tabBarController tabBar]items]objectAtIndex:3]setEnabled:TRUE]; return; } else { // invalid information UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"alert" message:@"Invalide Information" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show]; return; } } </code></pre> <p>I hope it helped :D</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload