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

  • Home
  • SEARCH
  • 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 8899665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:54:47+00:00 2026-06-15T00:54:47+00:00

I have 5 tab bar items. The first one will be the login page.

  • 0

I have 5 tab bar items. The first one will be the login page. When the user haven’t logged on other tab bat items will be disabled, but when the user logged by clicking the navigationItem button all the other 4 tab bat items will be enabled.

I have made searched and found nothing… 🙁

Here’s my code:

MainTabViewController.h
#import <UIKit/UIKit.h>

@interface MainTabViewController : UITabBarController
@property (retain, nonatomic) IBOutlet UITabBar *MainTabBar;

@end


MainTabViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.


    UITabBarItem *tabBarItem = [[MainTabBar items] objectAtIndex:1];
    [tabBarItem setEnabled:FALSE];


}

LoginViewController.h



#import <UIKit/UIKit.h>

@interface LoginViewController : UIViewController
@property (retain, nonatomic) IBOutlet UITextField *CustomerUsername;
@property (retain, nonatomic) IBOutlet UITextField *CustomerPassword;
- (IBAction)ResignKeyboardClicked:(id)sender;

@end

LoginViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    UIBarButtonItem *btnGo = [[UIBarButtonItem alloc] initWithTitle:@"Login"     style:UIBarButtonItemStyleBordered target:self action:@selector(loginAction)];
    self.navigationItem.rightBarButtonItem = btnGo;

}

- (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=%@&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];

    return;
    }
    else
    {
        // invalid information
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"alert" message:@"Invalide Information" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];

        return;

    }
}

For now my code only disable the other 4 tab bar items but I do not know the way to enable all the tab bat items when the user is logged in.

Please help?

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-06-15T00:54:48+00:00Added an answer on June 15, 2026 at 12:54 am

    I have to say that I am a beginner in iOS development bit I think I can help you.

    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:

    [[[[self.tabBarController tabBar]items]objectAtIndex:1]setEnabled:FALSE];
    [[[[self.tabBarController tabBar]items]objectAtIndex:2]setEnabled:FALSE];
    [[[[self.tabBarController tabBar]items]objectAtIndex:3]setEnabled:FALSE];
    

    And again you can enable them with:

    [[[[self.tabBarController tabBar]items]objectAtIndex:1]setEnabled:TRUE];
    [[[[self.tabBarController tabBar]items]objectAtIndex:2]setEnabled:TRUE];
    [[[[self.tabBarController tabBar]items]objectAtIndex:3]setEnabled:TRUE];
    

    So your LoginAction function would look like this:

    - (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=%@&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;
        }
    }
    

    I hope it helped 😀

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

Sidebar

Related Questions

I have 2 tab bar items. The first tab have a navigation controller(3 views)
So I have 3 main scenes, each with a tab bar item. The first
I have a tab bar controller and in both tab bar items i have
I have a UITabBar in my application with three tab bar items. At certain
I have a UITabBarController as my MainWindow.xib . I have 3 tab bar items
I have a tabbar application. And the item of first tab is Navigation Controller.
I have a tabBar, and I want to customise the items in the tab
I have a tab bar along with navigation controller iphone application. Now I need
I have a tab bar controller in the master view of a split view
I have created tab bar programmatically in the view controller. In my application, Initially

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.