I have a SplitViewController for my iPad application and I want to push a screen on top of it when it launches so I can have a login screen. The problem is that I have not been able to get a screen to hide the main and detail screen.
I can not use addsubview since the rootview is not hidden.
Well you can do this simple thing, make loginview controller rootview controller
In application:didFinishLaunchingWithOptions: make
self.window.rootViewController = self.loginViewController
and on successful login make your splitviewcontroller root view controller
appDelegate.window.rootViewController = appDelegate.splitViewController
To do this type of thing you would have to create your own implementation of a SplitViewController. One popular implementation is MGSplitViewController.
Related
I want make a typical tabbar based application.
And I want to insert login view on startup before main tabbar is shown.
I tried to insert TabbarController in main view, but cannot find appropriate code. All sample code I found is insert TabbarController on startup. (in Delegate file)
My fellow suggest create toolbar on startup but hide it at login view, but I am not sure if this is a general method or not.
In this case, what is a 'recommanded' handling method of TabbarController ?
A simple solution would be to
1-Add the tab bar to UIWindow in the appDelegate as is suggested by apple.
2-then add a UINavigationController in tabbar using tabbarController.viewControllers=[NSArray arrayWithObject:yourNavController];
3- Now after alloc init on your login controller write this code before pushing it to the navigation controller of the tabbar
yourLoginController.hidesBottomBarWhenPushed=true;
4- push yourloginViewController to the navigation controller of the tabbar.
5- After authentication before pushing your MainviewController instance on the navigation set it like this
MainviewController .hidesBottomBarWhenPushed=false;
I hope these five simple steps will do the magic for you cheers :)
Please let me know if it helps you.Thanks
The approach I use for login screens which works great is:
prepare and show the regular main screen (tab bar controller with whatever initial VC you want to use)
immediately present the login screen modally (without animation) from the tab bar controller (which will obscure the tab bar controller, which is what you want)
make the login screen the startup image
My name is Luca and I am experiencing an issue in my app after upgrading my XCode for ios 5. I really can find a solution to that, so I hope that someone can help me.
My software is a window-based application that uses a navigation controller and a toolbar item. The navigation controller is connected in mainWindow.xib to the application delegate navigation controller property (IBOutlet). The navigation controller init with a root view controller that I call 'starting view controller' (this is done in IB). The app has the status bar visible on top.
In my application delegate I do:
[application setStatusBarStyle:UIStatusBarStyleBlackOpaque];
application.statusBarHidden = NO;
self.window.rootViewController = navigationController;
[window makeKeyAndVisible];
[startingViewController onLaunchApp];
Once the app has finished loading I try to present another view using the Modal View Controller. The Modal View Controller is presented in the root view controller (starting view controller) by doing
[self presentModalViewController:'another view' animated:YES];
Here comes my issue. Once I dismiss the modal view controller, the navigation controller moves on the very top of the main window pulling up with it the root view controller. Part of the navigation bar lies behind the status bar (20 px) and other 20 px of white space are left at the bottom of the root view controller. Therefore my view becomes completely messed up and the only way to fix it is to rotate the device in landscape and then back in portrait orientation. After these operations the whole views' stack is ok and if the modal view controller is presented and dismissed again everything works just fine. In other words, this problem occurs only the first time the modal view controller is dismissed.
I have tested the app with all the simulator versions and they all work correctly except for the latest 5.0.
I spent the last 6 hours reading documentation, posts and trying to fix the app, but no luck.
I would appreciate a lot if someone could help me or give me any hint.
Thank you very much in advance.
If you haven't implemented it this way, try to dismiss modal view controller from the root view controller.
In my app, I require the main page to contain a toolbar at the top of the view. This view has a tableView. So my application cannot have a NavigationController.
Problem
When I want to navigate to the other view on click of the tableview cell then I am using the "pushViewController:animated:" method but it doesnt seem to work.
I checked the connections in IB. They are fine.
How can I navigate between pages without navigation controller??
I do not want to use the modal view for other views.
Please Suggest some Method.
You can use an instance of UINavigationController without having it displayed and using it for navigation.
Load your first view controller with your instance of UINavigationController in your appDelegate implementation.
Like:
FirstScreenController *fsc=[[FirstScreenController alloc]initWithNibName:#"FirstScreenController" bundle:nil];
UINavigationController *navigation=[[UINavigationController alloc]initWithRootViewController:fsc];
navigation.navigationBar.hidden=YES;
[window addSubview:navigation.view];
Here FirstScreenController can be your view controller having the toolbar and tableview.If you want to display another view on any click of the tableviewcell, call it this way.
[self.navigationController pushViewController:secondviewcontroller animated:NO];
I have created an UITabView application. Each view selected from the bar is a seperate controller with own nib file. I switch between them succesfully.
In the first view I have two buttons (check out the screenshot). When clicking them I want to switch to another views which are the parts of the current view controller. I use:
[self presentModalViewController:anotherViewController animated:NO];
That switches the view, but hides the UITabBar. How to keep the bar on the screen after the switch?
P.S. Sorry for the blurred image. I am not allowed to share to much info.
Well I think you are misusing the modal view controller. For a problem like this I'll say you should put them in a view controller stack using UINavigationController. Instead of making each tab a UIViewController make it a UINavigationController, then you can push and pop view controllers on it, which still show the tab bar.
See http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UINavigationController_Class/Reference/Reference.html
use: tabBarController.selectedViewController = newViewController
edit: UINavigationController is not needed here.
I've got a sample application on http://github.com/niklassaers/Test-iPhone-TabBar-App that shows my problem: I have a regular view-based application, and at some point (in this case when I click a button) I want to load a tabbar controller and display it. I believe this is what I should be doing:
MyTabBarController *tabs = [[MyTabBarController alloc] initWithNibName:#"TabBar" bundle:nil];
[self.view addSubview:tabs.view];
Unfortunately, this brings up a bit of black in the bottom of my main view and nothing more. I believed it should bring up the tabbar, the tabs, and the selected view. What is the correct way of loading a TabBarController (or making a TabBar controller if that's what I've done wrong) in a view-based application?
Cheers
Nik
You should use a UINavigationController, then just push the tabs controller onto the nav controller when you're ready to display it.