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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:43:00+00:00 2026-06-13T19:43:00+00:00

I have added a UITabBarController programatically (Search,Login) and I want to set second tabbaritem(Login)

  • 0

I have added a UITabBarController programatically (Search,Login) and I want to set second tabbaritem(Login) and its view to be selected when Login credentials are not correct.But I m unable to do it so ..Could not understand where I m going wrong ..?

    Search *first = [[Search alloc] initWithNibName:@"Search" bundle:nil];
    first.title=@"Search";
    Login *second=[[Login alloc]initWithNibName:@"Login" bundle:nil];
    second.title=@"Login";
    NSArray *viewArray= [NSArray arrayWithObjects:first,second, nil];
    tabBarController=[[UITabBarController alloc] init];
    [tabBarController setViewControllers:viewArray animated:NO]; 
    [tabBarController setSelectedIndex:2]; 
    [self presentModalViewController:tabBarController animated:NO];

But here my SearchViewController is selected and displayed as default…Where i m going wrong..?

  • 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-13T19:43:02+00:00Added an answer on June 13, 2026 at 7:43 pm

    Error is in this line:

    [tabBarController setSelectedIndex:2]; 
    

    Counting starts not from 1 but from 0, so in your case you have to change it to:

    [tabBarController setSelectedIndex:1]; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view controller that's been added to a UITabBarController . In this
I have a UITabBarController as part of my app delegate and I want to
I have a root UIViewController subclass that has a UITabBar, (I'm not using UITabBarController)
I have a UINavigationController inside a UITabBarController. I'm presenting a sort of popover view
I have a UITabBarController and want a button seen only on one of the
I have 6 view controllers on a UITabBarController. Each of them has a UINavigationBar
I have written a UITabBarController subclass (called MainViewController ) and added a few instance
I have UITabBarController with 6 tabs. Now, the last 2 screens(tabbar items) are added
I have a UITabBarController with several UiTabBarItems. Every TabBarItem leads to a NavigationController where
I have added selectionDidChange event for my Ember.Select, but when my view loads it

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.