IPhone application won't launch correctly - iphone

So I'm developing and iPhone game right now and everything has been working just fine when I test it on my first gen iPod touch. Last night, I added in some NSUserDefaults stuff to save a few variables for it. I ran it on the simulator a few times and it worked perfectly, but when I built the app and put it on my iPod, all I got when I launched it was a black screen. Anyone have any ideas? They would be much appreciated, thank you.

I recommend deleting the application from your iPod Touch first then trying to install it again. When are you trying to read from NSUserDefaults? In your applicationWillFinishLaunching call? If so, try to comment that out to ensure that it really is the source of your problem.

You need to run it on the iPod touch with the debugger switched on - you should be able to track this down.
Do you know about setting a breakpoint for exceptions - if you tell the debugger to break on objc_exception_throw it is extreemly useful in these cases.

Do you have a custom Default.png file? If no, then you will see a black screen while your application loads. Depending what type of (possibly unending) operations you are doing on load this might be the reason you are seeing a black screen. Remember the simulator runs on top of the processor in your mac which is significantly faster than the processor in your iPod Touch.

Related

App works on iphone simulator,iphone device, ipad simulator but not ipad device

So I made an app, And it runs on all possible platforms except the ipad device. I would understand if it ran on the ipad device and not the iphone device since the processor is better on the ipad, but this has me stumped. It also worked fine on the ipad simulator. Can anyone think of a reason why this could be?
There are too few details to give an explanation. A possibility is: when you run the app in two different devices, iPhone and iPad, some nib files could be different. Even the app delegate is different if you use XCode templates for universal apps. So this means that it is possible that the code executed is different in the two devices.
So imagine that in the iPad app delegate / view controller you're allocating - at launch - a lot of memory (scroll view with many large images for example). Then the app will not crash in the simulator (it uses your Mac memory). The app will not crash in the iPhone (different code). So at the end it will crash in the iPad only.
Other possibilities: you're going short in memory very soon. But the iPad 1 has less memory than iPhone 4G.
Other possibility: the watchdog timer kills your app at launch. It happens on the iPad 1 only because you're loading a few large images and it takes a lot of time, just enough to be killed by the watchdog.
Other possibility: iPad 1 is still with iOS 3.2, while iPhone and simulator are linked to iOS 4.0. In this case it is easy to have the app crashing in iPad 1 by calling one of the many new APIs introduced with iOS 4.
As you can see there are many possible explanations...
add target for device or convert it to universal application
Yes, it's easy to target both platforms. If you login to ADC and read the Programming Guide, it'll provide the basics for specific development. I can't legally speak of the "how."
Um. If you follow their directions, build two targets, share your source within the same project... then you'll be set. It's the same SDK, just different Nibs & main(), from what I can tell.
You say different xibs... you might be missing an Outlet connection somewhere.
Ok gents, sorry but I did not provide enough information for any of you to correctly answer this, but! here was my problem.
I had a login screen with 2 textfields, and a submit button. The submit button would release the current view and add a new view. I would usually press submit while the keyboard is being shown. Aparantly this makes everything blow up. You must manually hide the keyboard first. Hopefully this saves somebody some time.

iPhone OpenGL ES app killed on iPad when using "2x" button

Hey, I got kind of a weird issue here.
I have an iPhone-only OpenGL ES app which runs fine on all iPhone and iPod touch models supported.
When running on the iPad, it runs on an iPhone-sized window as expected, and pressing the "2x" button once scales up the window to twice the size, as expected, and the app continues to run without problems.
But if the user taps the "2x" button 3 or 4 times quickly, the app is killed with the Program received signal: "0" message (which, from what I understand, means the OS killed my app for using too much memory, is that right?)
What I really do not understand is what in my app could possibly be using up more memory when the iPad scales the window up and down? As far as I know there's not even any way for my app to tell if and when the iPad is doing that. I don't know if the fact I'm using OpenGL ES is related or not, but that issue doesn't happen on any of the Cocoa Touch apps I have - though it also doesn't happen on the other two OpenGL ES apps I have. And this app does use more memory than any of the other ones.
Anyone ever had or even heard of this problem? Googling gave me nothing.
Since no one has posted with a direct answer (your situation might be a little vague), I have a suggestion for how to move forward and gather more information on what might be causing your problem.
Check out the Instruments in Xcode which can identify memory leaks:
Instruments User Guide
Or for an even friendlier introduction, here's a video that address performance issues, including memory leaks (and how to find them). iOS Performance Optimization Video
Just adding this so there's some kind of an answer here...
I never figured out what the hell was going on with the 2x button.
The way I fixed it back then was to optimize memory usage as much as I could, lazy-load all that I could and unload again when not in use.
Weird that it never complains about memory when running on any of the supported iPhone or iPod touch models, even the older ones, but it got killed on the iPad ONLY when pressing the 2x button repeatedly and quickly... I guess that's always gonna be a mystery to me.

iPhone - fast-app switching and iOS 4

I'm trying to get the following functionality in my iPhone app:
When backgrounded, stays running (doesn't have to do any background work)
When resumed, app picks up where it was left off
I'm mainly wanting the same screen on my app still up, as there are several UINavigationControllers within a UITabBarController.
I have done all of the following:
Made sure I'm compiling with 4.1 SDK
Set UIApplicationExitsOnSuspend to false
Handle DidEnterBackground and WillEnterForeground in my AppDelegate
Call BeginBackgroundTask in DidEnterBackground, to attempt to keep my app open
I'm using MonoTouch, but that it probably beside the point. I can take answers in Obj-C, for sure.
I've tested my app on a jailbroken phone with Backgrounder, and I see the "app in background" badge disappear immediately after pushing the home button. I also tried setting UIBackgroundModes in my Info.plist, but to no avail.
Is there anything I'm missing?
Or is this something I would have to implement on my own to resume the previous state of my app? Everywhere I've read talks like it should just work automatically.
If you don't want to be doing work in background, don't call beginBackgroundTask. That call is for situations where you want to do some kind of work in the background. And if you don't finish that work fast enough, iOS will terminate your app.
When I upgraded to iOS 4.x, my MT application started exhibiting this behavior without me having to do anything. iOS should take care of it for you.
I finally got in touch with someone on MonoTouch's irc.
In MonoDevelop there is an option to make a dual iPad/iPhone project, which I used. This is causing my app to behave as if it's running with the 3.2 SDK when deployed to the device.
I think my solution is to install the iOS 4.2 SDK that just came out, since this ads the new multi-tasking feature on iPad.
Not only do you need to support going into the background, you also need to support cases where your app has been terminated. In your app’s initialization code, you should resume the state that it was in. For instance, when you push a view controller, use NSUserDefaults to store a value for the currently-displayed screen, and then when you start read that value and display the associated screen.

GUI is stuck with uibackgroundmodes= voip, audio

I have tabbar-based application. When I put in my plist UIBackgroundModes (my application is supposed to support voip), the GUI doesn't load. It sucks on Splash screen and doesn't load the first tab view. When i remove the UIBackgroundModes property from info.plist, it works fine. More than that, pressing the home button when it stuck does nothing. Did somebody encountered a similar problem? (The problem exists on simulator)
Thanks,
Nava
It appears, that the problem happens on Simulator only, it works on the device... So the solution (temporary one) is not to put UIBackgroundModes into info.plist for simulator version.
You are responsible for loading/unloading the interface when going in and out of the background mode. You'll also need to update the interface accordingly when coming out of background.
iOS helps a bit by taking a screenshot before putting the app in background and displaying it when getting the app to foreground (a bit like Default.png when starting the app) and also some UIImage caching.
It might be worth sharing some code.
Supporting Background State Transitions
Supporting the background state transition is part of the fundamental architecture for applications in iOS 4 and later. Although technically the only thing you have to do to support this capability is link against iOS 4 and later, properly supporting it requires some additional work. Specifically, your application delegate should implement the following methods and implement appropriate behaviors in each of them:
application:didFinishLaunchingWithOptions:
applicationDidBecomeActive:
applicationWillResignActive:
applicationDidEnterBackground:
applicationWillEnterForeground:
applicationWillTerminate:
Being a Responsible, Multitasking-Aware Application
Applications that run in the background are more limited in what they can do than a foreground application. And even if your application does not run in the background, there are are certain guidelines you should follow when implementing your application.
Do not make any OpenGL ES calls from your code. You must not create an EAGLContext object or issue any OpenGL ES drawing commands of any kind. Using these calls will cause your application to be terminated immediately.
[...]
iOS Application Programming Guide
I see this bug as well. It's very annoying. It's as if the app is stuck in the simulator and won't keep going. When this happens, I know how to "unstick" it.
In the simulator I just go to menu Hardware > Lock and then unlock the phone again. Now I stop the debugger and start the app again. This seems to kick it back to life.
Fortunately this bug doesn't happen on a real phone, only in the simulator.

How to run my app even after iPhone screen locks?

I want my app (LaunchDaemon) to keep running even if user locks the iPhone. My LaunchDaemon simply check a file and if some condition is true, it displays an Alert to the User. Its working great when iPhone is on Home Screen, but it is not working when user Locks the Screen.
I want something Similar to Alarm app of iPhone which will show an Alert even if the iPhone screen is Locked.
Any suggestions on how to do this? BTW i am developing for JB iPhone.
OS powers down the device and suspends your app after about 30 seconds after screen is locked. However,
if your app is playing a sound OS will not do that. Hence what you need to do is play a silent sound in a loop.
Alright i have solved this problem too.
Here is a very good tutorial on how to prevent deep sleep of iPhone.
Prevent iPhone Deep Sleep
It took me quite sometime to made this work, as NSRunLoop was not running for me automatically.
Hope this will help someone else also.
Best of Luck !!!