0

I m very much new to iPhone development and strucked at a point .I have a UIViewController in which Im placing a tab bar and tab bar items(Search,Login) on it ..Now on startig up of the app how can I keep Search tabbaritem selected?.And If I click on login it has to redirect to another UIViewController(Login).But in UIViewController I dont need the tabbar.How can I make tab bar item to respond when login is clicked and redirect to some other view...?

07405
  • 193
  • 4
  • 14
  • if you want to show login viewcontroller and after login the tabbar controller should appear, your question is answered here http://stackoverflow.com/questions/2716755/showing-login-view-controller-before-main-tab-bar-controller – iNeal Oct 25 '12 at 08:52
  • No what I need is first in a UIViewController I have to provide a tabbar .then if login tabbar item is pressed it has to redirect to loginviewcontroller ..How to make login tabbar item to respond and redirect to loginviewcontroller if it is clicked ? – 07405 Oct 25 '12 at 09:02
  • Please check this link which has all the beginner examples. Try tabbarcontroller example http://fromideatoapp.com/downloads/example/ – iNeal Oct 25 '12 at 10:02

2 Answers2

0

From your question. It's clear that you don't need tabbar. Instead add tabbarcontroller.

Check the image I've attached . That will show you the overlay about what you should follow. You just need to add tabbarcontroller from nib objects. Then add your viewcontrollers for a given tab

Let me know. If anything is unclear.

Enjoy programming.

Niru Mukund Shah
  • 4,637
  • 2
  • 20
  • 34
  • No first I have creted a UIView application and placed some textfields and labels on it .Now I have to add a tabbar .Im doing it by dragging from library and adding tabbaar items.They are getting added.But what I want is the first tabbaritem to be selected on app startup bcoz the startup view is search view and first tabbar is also search?.Now when I click on second tabbar item 'Login'it has to redirect to another view 'LoginVieweController.Now how to rediret to another view when login tabbar item is selected? – 07405 Oct 25 '12 at 09:15
  • So basically you want your LoginVieweController as & when app starts . then after clicking login button you need your tabbar. Correct? – Niru Mukund Shah Oct 25 '12 at 09:18
  • No ..Let me explain u clearly..When app starts SearchViewController with UILabels and UItextFields and tabbar with two tabbar items(Search,Login) will appear with Search tabbar item selected.Now after the app appears when I click on Login tabbar then it should redirect to LoginViewController.In loginViewController I dont have any tabbar.I have only textfields and button.. – 07405 Oct 25 '12 at 09:23
  • did you assign your LoginVieweController as your second tabbar controller from nib? – Niru Mukund Shah Oct 25 '12 at 09:28
  • ok. how you have assigned your searchviewcontroller as your first tabbar item? – Niru Mukund Shah Oct 25 '12 at 09:32
  • No I have not.I donno these items how to do ?How to assign searchviewcontroller as first tabbar item and LoginVieweController as your second tabbar controller from nib – 07405 Oct 25 '12 at 09:34
  • ok. that's why I've attached this image.Instead of adding tabbar then tabbritem in it. can't you add tabbarcontroller? – Niru Mukund Shah Oct 25 '12 at 09:37
  • But I have already placed labels and textfileds on the view .Now I guess I have to add them again to tabbarcontroller again if Im not wrong.. – 07405 Oct 25 '12 at 09:40
  • No. You don't need to add them again. As it already resides in your searchviewcontroller itself. – Niru Mukund Shah Oct 25 '12 at 09:41
  • But if I drag and drop tabbar controller on the view I couldnot see it when I run the app – 07405 Oct 25 '12 at 09:46
  • ok.Are you working with singleview application or with some other? – Niru Mukund Shah Oct 25 '12 at 09:49
  • ok. So if you want tabbar throughout the app then add it on mainwindow.xib – Niru Mukund Shah Oct 25 '12 at 09:56
  • I dont want it through out the app.I just want it on SearchViewController which apperas when app starts up – 07405 Oct 25 '12 at 09:57
  • ok. then add tabbarcontroller in the nib where you are adding searchviewcontroller – Niru Mukund Shah Oct 25 '12 at 10:04
  • suppose your searchviewcontroller launches directly from appdelegate then add t at mainwindow.xib. or if your searchviewcontroller loads from some viewcontroller's click event then add it there – Niru Mukund Shah Oct 25 '12 at 10:06
  • Yes searchviewcontroller launches directly from appdelegate and I have added it to mainwindow.xib >But on running the app still I couldnot see it – 07405 Oct 25 '12 at 10:19
  • ok. add tabbarcontroller in mainwindow.xib below your window. As you can see in image, mine tabbarcontroller is below my view while yours will be below window – Niru Mukund Shah Oct 25 '12 at 10:22
  • k I have added it and can see it at the botto of window.But still when I run I couldnot see it at he bottom.Should I connnect anything elz like delegates ..? – 07405 Oct 25 '12 at 10:52
  • yes give outlets to uitabbarcontrolles from appdelegate's .h file – Niru Mukund Shah Oct 25 '12 at 10:54
  • K I got it .I can see now when I run the app.Can u please tell me how to redirect to another view when Login tabbar item is clicked ..? – 07405 Oct 25 '12 at 11:24
  • see my attached image. Your nib should be like this.when you expand your tabbarcontroller . you should be able to see view controller - item. in first item name your searchviewcontroller class & its related nib name in its properties then follow the same steps for view controller item2 that would be your loginviewcontroller – Niru Mukund Shah Oct 25 '12 at 11:35
  • But I couldnot see all those Objects -->I m unable to expand them .Mine is iPhone 4.3 simulator – 07405 Oct 25 '12 at 11:44
  • np. though you should be able to see those. check again. – Niru Mukund Shah Oct 25 '12 at 11:53
  • Sorry if Im asking many questions.But now when I try to keep cursor in textfield of SearchViewController ,I couldnot keep it ..Y ? – 07405 Oct 25 '12 at 12:01
  • need to check your nib for that. – Niru Mukund Shah Oct 25 '12 at 12:15
  • please refer http://www.mobisoftinfotech.com/blog/iphone/iphone-tabbar-uitabbarcontroller-tutorial/ . So you can get basics about uitabbarcontroller. – Niru Mukund Shah Oct 25 '12 at 12:19
  • what couuld be the possible reason that i am unable to keep cursor in textfield of SearchViewController? – 07405 Oct 26 '12 at 07:26
0

On click to login,follow this code to get the application begin from LoginViewController without the tabBar..

YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication]delegate];

appDelegate.window.rootViewController = LoginViewController;
AppleDelegate
  • 4,269
  • 1
  • 20
  • 27