App shows white screen on startup after upgrading to iOS 4.2 - iphone

For the past few weeks I have been working on an app that uses a SoundManager class that I found via the comments of this blog post:
http://www.gehacktes.net/2009/03/iphone-programming-part-6-multiple-sounds-with-openal/
The link to the SoundManager and tester app is provided in the comments by David Evans. I am not allowed to provide a second link so I'll mention the name of ZIP file he links to:
SoundTester.zip
I was very happy with this code, until iOS 4.2 was released. After updating my iPad and Xcode correspondingly, my apps that use the SoundManager class only show the navigation bar with it's title. The rest of the screen is white. It's not iPad specific behavior. I have seen the same on an iPhone4 and an iPhone 3G that upgraded to iOS 4.2.
When running the apps in the simulator, I get the same results. The problem is that I get no error messages in the console window and no build and compile errors at all. Very frustrating and very hard to fix for an iPhone developer that started using the iPhone SDK only months ago.
Does anyone have a clue what could have gone broken and how to fix it? Any help is appreciated!

Somebody please shoot me...
Just found the problem, with the help from a piece of code I had written down from the iPhone Developer's Cookbook.
The problem was not the SoundManager (which still works fine, fortunately!) but in the application:didFinishLaunchingWithOptions: method in the App Delegate class.
Here is the code that causes the problem in iOS 4.2 but still works in iOS 3.2:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Create a Navigation Controller on the fly.
// Use the View Controller as root view controller.
viewController.title = #"ThreeSounds";
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController];
nav.navigationBar.barStyle = UIBarStyleBlack;
// Add the view controller's view to the window and display.
[window addSubview:nav.view];
[nav release];
[window makeKeyAndVisible];
return YES;
}
The solution: remove the line that says: [nav release].
For some reason, releasing the navigation controller was not a problem in iOS 3.2.
In iOS 4.2 is makes the screen go white.
I found out that this method was the problem because it was the last method that was executed. That, in turn, I found out by adding this piece of code to every class in my project:
-(BOOL) respondsToSelector:(SEL)aSelector {
printf("SELECTOR: %s\n", [NSStringFromSelector(aSelector) UTF8String]);
return [super respondsToSelector:aSelector];
}
This piece of code logs all the methods that get called.

I used the following code in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
if (!window)
{
[self release];
return 0;
}
This method caused white screen when I launched my app. It was OK in 3.2 / 4.0 SDK. In SDK 4.3 it is causing the problem. Just comment or remove this code if you have it.

I had same problem. The problem was duplicated UIWindow.

Related

phonegap iphone app showing black screen on iPad

I am developing and testing my iphone app (phonegap + native) properly on iPhone simulator and device.
However, when testing on iPad simulator or device, I can only see a blank black screen and no errors on console.
Target family is properly set to iPhone and window makeKeyAndVisible also executed! How to solve it?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIViewController *introVC = [[videoViewController alloc] initWithNibName:#"videoViewController" bundle:nil];
UIViewController *blogVC = [[blogViewController alloc] initWithNibName:#"blogViewController" bundle:nil];
NSArray *viewControllers = [NSArray alloc];
viewControllers = [NSArray arrayWithObjects: introVC, blogVC, nil];
[rootController setViewControllers:viewControllers animated:NO];
self.rootController.selectedIndex = 0;
[window setRootViewController:self.rootController];
[window makeKeyAndVisible];
return YES;
}
A black screen is pretty much always an error in the javascript. Assuming you are using iOS 6 you should be able to attach the desktop safari web inspector and look for any javascript errors, which will not show up in the Xcode console.
Another thing to test is that the app still works as a clean install on iPhone - updating an existing app only copies new and updated files, so errors caused by deletion such as renaming a script and leaving a reference to the old filename won't show up right away.

iOS4 to iOS5, first view of tabBar app is not responding to touches

I have a tabBar App, with 5 tabs. The application was built in previous version of Xcode for iOS4.3. When I run this app from Xcode 4.3 (after changing the base SDK to 'Latest iOS'), in iPhone4.3 simulator the App runs fine. But when I run this App, in iPhone 5.0 simulator
App loads fine i.e. my first screen from the first View controller is loaded correctly. But no touches are recognised by the screen (on tableView, navigationBar and toolBar)
If I select another 'tab', the touch is recognised and touches in the other views loaded from other tabs work fine. Now if I go back to the first view, it works fine.
The tabBarControllers, navigationControllers and the viewControllers I created in Interface Builder and have following code in
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
[self.window addSubview:self.tabBarController.view];
[self.window addSubview:[self.navigationController view]];
[self.window addSubview:self.toolBar];
[self.window makeKeyAndVisible];
return YES;
}
I am missing something that iOS5 needs, but I just can't figure it out. If anyone else had similar problem, it would be great if you could share it and if you have a solution... that would be fantastic!
Just found my mistake...
I have bit more code in application:DidFinishLaunchingWithOptions where I am initialising other properties of the App and further down in the code, I have repeated the code
[self.window addSubview:self.tabBarController.view];
This must be creating another layer on top of my view and causing the view to not respond.
(knew I would find the answer on stack overflow :).... so as soon I post the problem here, I see my mistake)

2 XIB and 1 viewcontroller but functions don't work in the ipad XIB

I believe that I did everything necessary to change my app for ipad (was for iphone at start). I can toggle the build status to either iphone (only), ipad (only) or iphone/ipad - and the app launches either in ipad or iphone simulator. I can do that forth and back at will.
I added the idiom to check for ipad and basically for one of my xib, instead of using the string of my xib to create the controller, I use the one for the ipad. So it is a new xib for ipad with all same graphical objects ( enlarged ;-) ) . I added the callbacks to function correctly with IB.
I can see everything fine and arrive on my new ipad view BUT when I click on one of my buttons... nothing happened like if my callbacks don't work. It is very surprising and actually I have no idea where to look as I compared most of the parameters between my iphone and ipad view and they are identical as far as I can see.
It must be something damn obvious so if one of you had the same issue and it was a very simple answer ... I guess that would be what I missed!
Thanks for your help in advance
Cheers,
geebee
EDIT1: Some code as requested
at start I have that to decide either way:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
examTFVC_NIB=#"ExamTFViewController-iPad";
}
else
{
examTFVC_NIB=#"ExamTFViewController";
}
Then to go to the right view:
ExamTFViewController *examTFViewController = [[ExamTFViewController alloc]
initWithNibName:globals.examTFVC_NIB bundle:nil];
But I have no problem loading the correct XIB. The issue is really the callback functions not being called...
Thanks for the help.
EDIT2:
I also realised that calling the extension of the xib xxx~ipad allows to avoid the example code above. And it works - but still no function can be called.
EDIT3:
IMPORTANT FINDING: if I move my buttons higher and on the left of the screen: they work! So it seems that the functions are called if the event are in the region of an iphone screen although I am on an ipad screen. I guess know it would be more obvious to find the issue! thanks for any help – geebee just now
ANSWER
iPad touch detected only in 320x480 region
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// to correct region size
CGRect rect = [[UIScreen mainScreen] bounds];
[window setFrame:rect];
// now, display your app
[window addSubview:rootController.view];
[window makeKeyAndVisible];
}
** OR OTHER SOLUTION **
Check the full screen at launch checkbox - only present in the ipad xib MainWindow
finally solved - with 2 methods - programmatically or via IB - in the edited section of the post.

XIB loads in iOS 4 but doesn't load in iOS 5

I created an app in Xcode 4.1 and now i upgraded it to 4.2 so i could use the iPhone 5 simulator.
I have an app that uses a tab bar to loads 3 views. They load correctly in iPhone 4 but in iPhone 5 simulator that doesn´t happen. I´m able to see my xib (with no content) that i load initially, but there are no tabs to choose from.
Apple made some changes in the projects in Xcode 4.2. Now they have storyboards which i don´t have because i created the app in Xcode 4.1. Anyone knows a work-around this?
The only code i think it may be usefull..
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[window addSubview:montraViewController.view];
[self.window makeKeyAndVisible];
return YES;
}
I was loading the view in viewDidAppear, that method was triggered when the view appeared in iOS 4 but in iOS 5 that didn´t happen. So i changed my "load controls" to the method viewDidLoad and they loaded correctly. Don´t take this has a bug, because it´s more probable to be bad programing.

When I Build and Run my iPhone Application on the simulator, Only a White screen Comes Up

I don't know what could be causing this. I chose "View Based Application". I just installed the newer (although not the newest) version of xCode, so to try it out, I made a tester application. I made a button that when clicked, alternates a label between shown and hidden. The program ran, no errors or warnings, but when the sim. brings it up, all there is is a blank screen with no button or label. I am truly clueless...
$- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
[window addSubview:viewController.view];
[window makeKeyAndVisible];
return YES;
}
$
I don't know if there is something corrupt with this App Delegate method, but it seems as though that may be the problem (as this is the method loading and making the .xib file visible.
Thanks in advance!
You are missing this line:
self.window.rootViewController = self.viewController;
If it is still not working, I would recommend making a duplicate project and just copying and pasting the App Delegate code from that into your current project.
In the code where you create the button, do you add the button to the view? It would be done like this
[viewController.view addSubview:button];