I just tried to duplicate an existing iOS project. After copying over all the files, and fixing all the errors, I am simply getting a white screen when the app launches. Any ideas? I do not have any MainWindow.xib files, nor are any xib files mentioned in my plist. Here is my launch code below:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
MainMenuViewController *mainMenu = [[MainMenuViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mainMenu];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
return YES;
}
When i set a breakpoint in MainMenuViewController's viewDidLoad method, it hits it just fine. Any ideas?
I just figured it out... all of my .xib files were missing from the "Copy Bundle Resources" section of Build Phases.
MainMenuViewController *mainMenu = [[MainMenuViewController alloc] init];
Had you set view's frame of mainMenu?
Related
I have duplicated iphone xib into iPad xib by duplicating the target, now my most of the xibs are converted properly into iPad size, however some xibs still showing as iphone size only. Apart from that most of the GUI functionalities like Alert View showing, Action sheet are all not as per iPad. What changes do I need to make to work perfectly for iPad.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
Edit: GUI ISSUE I have given two option in that Action sheet YES and NO, only YES showing NO is hiding somewhere..
thanks
Problem is not with conversion, Its with the usage of Action sheet in ipad. Check how to use Action sheet in ipad,
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIActionSheet_Class/Reference/Reference.html
it may fix your problem
You aren't loading the correct NIB when the app starts. This is the code provided by the Xcode "Single View" App Template, which detects the device and loads the appropriate NIB file:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[MainViewController alloc] initWithNibName:#"MainViewController_iPhone" bundle:nil];
} else {
self.viewController = [[MainViewController alloc] initWithNibName:#"MainViewController_iPad" bundle:nil];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
I'm using xCode 4.3.2 and started a blank application.
I have a navigation controller and a simple logincontroller. I want the login controller to be my root view so it is this first thing that a user does when they login.
I'm using the following code and when I run the application it displays a black screen. I put in logging in the LoginViewController.m->ViewDidLoad and it is being run is there something im doing wrong the LoginViewController.xib is very simple it just contains a button right now that will switch to a tab view controller once I figure this out.
Thanks in advance.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
UIViewController *loginController = [[LoginViewController alloc] initWithNibName:#"LoginViewController" bundle:nil];
navigationController = [[UINavigationController alloc] initWithRootViewController:loginController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window addSubview:navigationController.view];
[self.window makeKeyWindow];
return YES;
}
This is not right:
[self.window addSubview:navigationController.view];
change it to this:
self.window.rootViewController = navigationController;
I am new to iPhone app. I was told not to use Xcode storyboard for the app to be compatible with iOS4.3 and under.
Right now, I have 2 pages showing using a tabcontroller, however I am trying to add a page that loads up first when the program is started (i.e. a Login page), after authenticated the user will land on the first page of the 2 tabs.
What would I need to do? Should I create a MainWindow.xib file?
Thanks!
James
You have (at least) two solutions. You can :
*Create the window the the didFinishLaunching function in your AppDelegate, with something like that:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
RootViewController *controller = [[RootViewController alloc] initWithNibName:#"RootViewController" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
self.navigationController.delegate = controller;
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
*or you can create the MainWindow.xib file with the AppDelegate and the window, and tell your app use this nib when launched. To do that :
In the .plist, enter MainWindow for the "Main nib file base name" characteristic.
I could use a little clarity here.
I've opened a project that is a completed iPhone app. Then selected the target, selected "Universal" from the Summary/Devices dropdown, and followed the prompt to "Make a Universal App."
Xcode created a folder "iPad" with the file "MainWindow-iPad.xib" within.
Fine.
Now I duplicated all of my other nib files, and added "-iPad" after their name. I.e. "MySpecialVC.xib" was duped and renamed "MySpecialVC-iPad.xib." The thought was that Xcode knows some zoodoo about finding the correct xib for the device.
Not so fine.
Then I read that the "-iPad" had to be "~ipad" (tilde, then lower-case ipad). This solved the problem with some of the xibs, but not all of them.
Dang if I can't figure this out. Is there a RIGHT way to do this?
When I create a new universal project, I get this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController_iPhone" bundle:nil];
} else {
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController_iPad" bundle:nil];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
So it's clear the code is explicitly choosing a xib file. Is this not the case for your project?
I set up my app a while ago using a tutorial for setting up the navigationbar in interface builder, but no longer use interface builder in any of my app and would much like to change this 1 thing which does use interface builder to being coded in. So my question is, I have a navigationbar which works, and which appears on the first view of my app, HomeView. How would I make this happen just as it does now, programmatically?
In the AppDelegate.m file, add this:
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
RootViewController *rootViewController = [[RootViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:rootViewController];
[window addSubview:[navController view]];
[self.window makeKeyAndVisible];
}
Be sure to add #import "RootViewController.h" at the top of the file.
Another way of adding the navigation bar programmatically, change the application:didFinishLaunchingWithOptions method of your app delegate like:
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RootViewController *rootViewController = [[RootViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:rootViewController];
self.window.rootViewController = navController;
[self.window makeKeyAndVisible];
}