unable to migrate app to iphone5 retina 4 - iphone

I had migrated some apps to iPhone5 but with this one I am unable to solve it. I follow same steps but now I haven't got xib layout to set autosizing for window because TabBarViewController is programmatically defined as rootController. Always I am getting the annoying black front and top bars.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
tabBarController = [[UITabBarController alloc] init];
NSArray *viewControllers = [NSArray alloc];
viewControllers = [NSArray arrayWithObjects: nil];
// Attach them to the tab bar controller
[self.tabBarController setViewControllers:viewControllers animated:NO];
// Put the tabBarController's view on the window.
[window addSubview:[self.tabBarController view]];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyWindow];
self.splashController = [[splashViewController alloc] initWithNibName:#"splashViewController" bundle:nil aidioma:self.idioma];
[self.window addSubview:[splashController view]];
[self.window makeKeyAndVisible];

To enable 4-inch display support, you need to add a file to the root of your project named Default-568h#2x.png.
So easy to figure out, right? :)

Related

How to add navigation controller in landscape ios6

While am trying to add navigation controller in landscape based app ios6 application it shows in Portrait Mode only like in the image,What change should i made?
In app delegate file coding,
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
[self.window addSubview:[navigationController view]];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
Check this to add UINavigationController in your app :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// start of your application:didFinishLaunchingWithOptions
// ...
viewController = [[ViewController alloc]init];
UINavigationController *navigationController = [[UINavigationController alloc]initWithRootViewController:viewController];
[self.window setRootViewController:navigationController];
[window makeKeyAndVisible];
[viewController release];
[navigationController release];
return YES;
}

Implement TabBar Application

I make an app in which First 4 screen has no tab bar But after that each screen has tab Bar.
So i added the tabbar in each nib file.
how can i implement the tabbar so it is working.
Help me!!
Without seeing code it's difficult to see where the error has been made, so i recommend you give the dev centre a go :)
Create tabBarController in your didFinishLaunching, but show it only after you show your first 4 screens without TabBar. This is a default didFinishLaunching, that is generated by Xcode when you chose standart TabBar app template:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:#"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:#"SecondViewController" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = #[viewController1, viewController2];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
Here you should replace this line:
self.window.rootViewController = self.tabBarController;
with your line of showing your controller. Something like this:
LoginViewController *loginViewController = [[LoginViewController alloc] initWithNibName:#"LoginViewController" bundle:nil];
loginViewController.delegate = self;
self.window.rootViewController = loginViewController;
Then, when you remove your last screen and want to show the tab bar, write this:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.window.rootViewController = self.tabBarController;
The main idea is that you just change the rootViewController of your app window.

Change tab bar item title and color programmaticaly

I have implemented a tab bar controller in my App Delegate, but it's just empty squares in the tab bar. I wish to could change title and images of them and also I want to know how use not only custom image I add, but "default" images implemented in Xcode ("calculator" image, "search" image).
If you have tab bar in a xib, you can see it in tab bar item -> attributes inspector -> Identifier, then there is a list, if you don't want to use custom images. So there is my appDelegate.m code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after app launch
UIViewController *banksList = [[FailedBanksListViewController alloc] initWithNibName:#"FailedBanksListViewController" bundle:nil];
UINavigationController *listNavigationController = [[UINavigationController alloc] initWithRootViewController:banksList];
UIViewController *first = [[BIDViewController alloc] initWithNibName:#"BIDViewController" bundle:nil];
UIViewController *second = [[BIDDailyCount alloc] initWithNibName:#"BIDDailyCount" bundle:nil];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:first,second,listNavigationController, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
You have to create your UITabBarItems your self.
In you appdelegate you could do something like:
UIViewController *banksList = [[FailedBanksListViewController alloc] initWithNibName:#"FailedBanksListViewController" bundle:nil];
banksList.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch tag:0];
return self;
It might be a good idea to move this to a custom initializer in the controllers for each tab.

Combine UITabBarController with UINavigationController

I tried to use an "tabbed application" with a navigation bar in it. With the default the tab bar works fine, but I just can't gat a navigation bar. I found some stuff about pushing the navigation-bar and stuff like that, but all the stuff I found was some years ago, so don't gonna help me. And the recent stuff is outdated to, since iOS5 and the new version of Xcode..
Could anyone point me in the right direction to combine a to solve this problem?
Keep the following facts in mind please:
I'm developing for iOS5
I'm using Xcode 4.2
Here's how you can achieve it programmatically.
Delete the reference to your main xib in [appName]-Info.plist
In main.m, load your delegate:
int retVal = UIApplicationMain(argc, argv, nil, #"myAppDelegate");
In the app delegate, load the tabBar, the navigation controller and the view in the navigationController.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// create window since nib is not.
CGRect windowBounds = [[UIScreen mainScreen] applicationFrame];
windowBounds.origin.y = 0.0;
[self setWindow:[[UIWindow alloc] initWithFrame:windowBounds]];
// View Controllers for tabController (one viewController per tab)
NSMutableArray *viewControllers = [[NSMutableArray alloc] init];
// first tab has view controller in navigation controller
FirstView *firstView = [[FirstView alloc] initWithNibName:#"FirstView" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:firstView];
[viewControllers addObject:navController];
SecondView *secondView = [[SecondView alloc] initWithNibName:#"SecondView" bundle:nil];
[viewControllers addObject:secondView];
// create the tab controller and add the view controllers
UITabBarController *tabController = [[UITabBarController alloc] init];
[tabController setViewControllers:viewControllers];
// add tabbar and show
[[self window] addSubview:[tabController view]];
[self.window makeKeyAndVisible];
return YES;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
NSMutableArray *arrayViewController = [[NSMutableArray alloc] init];
UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:#"FirstViewController_iPhone" bundle:nil];
UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:viewController1];
[arrayViewController addObject:navigationController1];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:#"SecondViewController_iPhone" bundle:nil];
UINavigationController *navigationController2 = [[UINavigationController alloc] initWithRootViewController:viewController2];
[arrayViewController addObject:navigationController2];
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = arrayViewController;
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
In iOS 5 it is no longer tolerated to change the view controller for a tab (no problem before iOS5). The only accepted controller is that defined in IB for that tab. So it is neccessary to install a navigation controller on this tab and give his view the navigation bar. Then you can push or pop your desired views without changing the tab's controller.
The basic theory is that you create a UITabBarController, and then put a UINavigationController inside that, and then put a UIViewController as the root view controller of the navigation controller. bryanmac just answered with a good code sample.

Display a Splash Screen Before Loading the Root Navigation Controller - iPhone

I am new bee in iPhone. I have implmented using some tutorials, a Splash Screen before loading the UIViewController. Now i want to implement a NavigationController in my application and want to display a Splash Screen before it. Since I am new in Iphone so i did not get any tutotrials or guides to make a Splash Screen before loading a Root Navigation Controller.
I have seen many methods in which they over write the Default.png file and so on. I dont want to implement that one. I want a sperate UIView to have my custom Images and text in it and display that UI View as a Splash Screen
can anybody Guide me please.
Thanks in advance
Here you go buddy. Have fun and happy coding....
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Add a splash screen
UIImageView *imgv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"splash.png"]];
imgv.userInteractionEnabled = YES;
[navigationController.view addSubview:imgv];
[imgv release];
[self performSelector:#selector(removeSplash:) withObject:imgv afterDelay:3.0];
[window addSubview:navigationController.view];
return YES;
}
- (void)removeSplash:(UIImageView *)imageView {
[imageView removeFromSuperview];
}
Use "self.window" to display the splash image first. If u simply write "window", the image will not be displayed and animated in the first view, since the image can't be directly linked to the window in that case. Write the following code in appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:#"MasterViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
UIImageView *imgv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"themes.png"]];
imgv.userInteractionEnabled = YES;
[self.navigationController.view addSubview:imgv];
//[imgv release]; If you don't use ARC, uncomment this.
[self performSelector:#selector(removeSplash:) withObject:imgv afterDelay:3.0];
[self.window addSubview:self.navigationController.view];
return YES;
}
- (void)removeSplash:(UIImageView *)imageView
{
[imageView removeFromSuperview];
}