No Navigation bar iOS7+ app - iphone

What is the best way to build an app without navigation bar ?
I'm going to work on an app from scratch which includes about few navigation but there is no navigation bar. Definitely there will be navigation controller.
I know we can hide navigation bar by setting hidden property as YES. Is there any best recommended approach to build such kind of app ?

Go to your plist and do the below
one more thing on add the below line
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[_navigationController setNavigationBarHidden:YES animated:NO];
}

Just be careful not to place the view contents below the status bar (that is if you don't hide the status bar) and to place a back button somewhere to manually pop view controllers.

Related

Adding a floating view to my app

My application uses UITabBarController to present 3 tabs, each tab has a UINavigationController that manag all the view controllers.
What I want to do is to add a view that will be "floating" above all views.
For example suppose I want to show my logo at the top-left corner of the screen, and I want this logo to stay on screen no matter where the user navigates, no matter witch tab he is on.
I suppose I need to add this logo to the UIWindow? I just wonder what is the best practice for doing it?
Dont add anything to the Window other than the navigation controller,or root controller. Trust me you will run into memory issues if you do this as Window isnt released but View Controllers are.
Add that floating view to to each view controller and put it as the last item in the list of subviews. You can design it once in IB or progmatically and duplicate it on each screen. This is the approach i always take and your suggested idea doesn't save you any time.
Indeed, a good place to place it is in the window just when the app launches. E.g.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//...
//... Setup root View Controller
UIView *extraView = [[UIView alloc] initWithFrame:CGRectMake(0,0,10,20)];
[extraView setBackgroundColor: [UIColor greenColor]];
[self.window addSubView: extraView];
return YES;
}

How to change initial tab bar selection programmatically

Having problems changing the initial tab bar selection on an application (i.e. the middle tab is selected on app launch rather than the leftmost tab). The app uses storyboards and the tab bar controller was added later on in development via the storyboard method.
tabBarController.selectedIndex = 1;
the above code doesn't work (because I don't have a custom view controller connected to my tab bar, just the default UITabBarController):
Done some googling and looked at many different resources and haven't quite found a solution for an app that wasn't initially created using Apple's template Tab Bar Application.
Since this is the initial view controller, and is not a subclass, you need to set this in your appDelegate.
In AppDelegate.m, add the following to your application:didFinishLaunchingWithOptions: method:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// Select the left-most tab of our initial tab bar controller:
UITabBarController *tabBar = (UITabBarController *)self.window.rootViewController;
tabBar.selectedIndex = 0;
return YES;
}
tabBar setSelectedItem: try using this in your viewDidLoad

The tab bar is shifted down outside the borders of the simulator

I have created an empty project (XCode 4.2 IOS SDK 5), I have added a new view to it and make it the root view controller inside the appDelegate, so when the app runs, it displays that view correctly, however, I added a tabbarcontroller to the view, created an IBOutlet for it inside the newly created view, and added this line to viewDidLoad method of the view:
[self.view addSubview:self.tabController.view];
so the tab bar loads correctly in the iphone simulator, but with a little problem that I couldn't fix: half of that tab bar is shifted down the simulator which prevents tabs' titles from appearing, exactly as in the following screenshot:
How can I fix this problem?
Most likely it's because of status bar. But, because subview where you inserting controller can be any size, most universal solution is:
[tabController.view setFrame:self.view.bounds];
(assuming self.view - is the view, where you adding it)
The view with the tab bar on is 480px high, but the view you're adding it to is smaller than that because of the status bar. This means that it starts 22px too low, and ends 22px too low - off the bottom of the screen.
If you want the tab bar to be global to the app link it to an IBOutlet on the app delegate, then do this in your didFinishLaunching method:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ...
// Add the tab bar controller's view to the window and display.
[window addSubview:tabController.view];
[window makeKeyAndVisible];
return YES;
}
This adds it to the main window, rather than another view. This will anchor it to the top of the screen, so the bottom will be at the bottom of the screen.

iPhone, how can I add a first view, show once, to a mainWindow but not have a tab bar button?

I need to have a view which shows first before other views but doesn't have a tab bar button.
Is there a way to do this ?
EDIT:
I don't want to show it modally as i want to use to standard function which show other views and having to cater for different ways of showing the view would be messy.
You could add your tabBarController in your window only once you need it and then remove your view from it's superview do discard it and free memory.
Something like:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}
- (void)showTabBarController {
[window addSubview:tabBarController.view];
[viewController.view removeFromSuperView];
self.viewController = nil;
}
So you want the tab bar to be visible, yet none of its items should be active and the visible view is not a part of the tab bar hierarchy? I don't think this is possible...
And even if you make things look like the described scenario, I have some doubts whether apple will approve an app circumventing standard functionality like this.
You mean UITabBarController?
Try use View Based Application or Navigation Based Application when creating the project in XCode

How are the 2 View Controllers wired to the tabBarController in iPhoneRecipes

I am learning iPhone programming by reviewing the iPhone Recipes sample application.
I am puzzled with how the two view controllers are wired to the tab bar. If they are wired in the XIB, can anyone explain how it is done or where I can get more visually aided details on connecting things in the XIBs.
This is my starting point in the learning process:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
recipeListController.managedObjectContext = self.managedObjectContext;
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
}
Basically, the view property of the tab bar is being added as a subview of the window.
The view property of the tab bar points at the tab bar's visual component, (the tab bar view itself) and the tab bar controller handles its behaviour (changing tabs, etc).
Each individual tab is a subview of the tab bar, so when the tab bar view is added as a subview of the window, its subviews are brought along for the ride. It's a little tricky to get your head around at first, but it should start sinking in after youplay around with interface builder a bit more.
All that's happening in the XIB is you're setting the view outlets on each tab so that they can be displayed when each tab is selected.
Hope this helps.