Build succeeds but black screen - iphone

The build process is fine but then i get a black screen. I tried putting a breakpoint in the app delegate but it doesn't seem to run.
What could it be?
This is my didFinishLaunchingWithOptions method:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Init Airship launch options
NSMutableDictionary *takeOffOptions = [[[NSMutableDictionary alloc] init] autorelease];
[takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey];
// Create Airship singleton that's used to talk to Urban Airship servers.
// Please populate AirshipConfig.plist with your info from http://go.urbanairship.com
[UAirship takeOff:takeOffOptions];
// Register for notifications
[[UAPush shared] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
usersData = [PlayersData sharedInstance];
//[usersData cleanUserDefauts]; // --- use to clean user defaults
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.loadingPageVC = [[LoadingPage alloc] initWithNibName:#"LoadingPage" bundle:nil];
self.window.rootViewController = self.loadingPageVC;
[self.window makeKeyAndVisible];
ConnectionManager *connectionManager = [ConnectionManager sharedInstance];
NSLog(#"Connection statement: %#",[connectionManager checkConnection]);
if ([[connectionManager checkConnection] isEqualToString:#"connected with wifi"] || [[connectionManager checkConnection] isEqualToString:#"connected with wwan"] ) {
[connectionManager getLocation];
}
return YES;
}

Sometimes(Very Rarely) XCode can behave different.If something is really weird i would do the following things.
Do a clean build
Remove your app in the Simulator and Build Again
Restart Simulator and Build Again
Close XCode and Reopen it
Worst case is to restart the System

No need to resart anything. Just follow a step given below & you will achieve what you want.
1. Go to /Users/<MAC_NAME>/Library/Application Support/iPhone Simulator/<SIMULATOR_VERSION>, delete all & run app
Enjoy Programming!

I think you may have changed your xib name from ViewController to LoadingPage.
If so, then you must have to delegate it from your .xib. From the top-right corner. Like,
I have just given my opinion that this may be your solution. If you have succeeded with another one, let me know.....:)

Ok! This is solved.
Apparently someone I work with changed one simple word and that messed everything up…
He made the appDelegate inherit from UIApplication instead from UIResponder.
Now it works.

Related

Estimote SDK - Beacons raging in background

First question is better is Estimote SDK or CoreLocation framework? I have app which is finding the beacons but now i must made an app which will find beacons when application is in background or even is terminated.
Setting up background detection is pretty automatic in iOS so long as you do it in your AppDelegate and receive callbacks in that class:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
CLBeaconRegion *region;
region = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:#"2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6"] major: 1 minor: 1 identifier: #"region1"];
region.notifyEntryStateOnDisplay = YES;
[_locationManager startMonitoringForRegion:region];
[_locationManager startRangingBeaconsInRegion:region];
return YES;
}
You can read more about what you can expect from detection times in the background here:
http://developer.radiusnetworks.com/2013/11/13/ibeacon-monitoring-in-the-background-and-foreground.html

How to create a custom alarm which can be set for random days in a week without using local notifications?

I have studied some of the following questions, that are::
1.) How to set alarm for selected days in iphone?
2.) iPhone alarm using repeated local notifications
3.) How to set the alarm in iPhone and save in local notification?
but they all are using local notifications. I am facing problem with local notification as I have to use three buttons on an Alarm View which are: Snooze, Ignore and Okay. I have to perform custom actions on each button click.
Please help me with this stuff.
Suggestions accepted.
Thanks in advance.
Kuldeep.
In you app delegate...
- (void) presentWidget: (NSString*)theDisplayedText {
BOOL widgetIspresent = [WidgetVC widgetIsCurrentlyPresented];
if (!widgetIspresent) {
WidgetVC *widgetVC = [[WidgetVC alloc] initWithNibName:#"WidgetVC" userInfoString:theDisplayedText bundle:nil];
widgetVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
widgetVC.userInfoStr = theDisplayedText;
[mainScreenManager presentViewController:widgetVC animated:YES completion:nil];
}
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif) {
NSLog(#"Recieved Notification didFinishLaunchingWithOptions %#",localNotif);
NSString *theDisplaytext = [localNotif.userInfo valueForKey:#"someKey"];
//here we have to handle whatever notification was pressed - that might also be an old aready passed one
//this all is checked when the widget opens - it will show if the notification is OK or too old
[self presentWidget: theDisplaytext ];
} else {
//so we started the app normally, not via local notification
[self presentWidget];
}
return YES;
}
// Handle the notificaton when the app is running
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)localNotif {
// Handle the notificaton when the app is running
NSLog(#"Recieved Notification didReceiveLocalNotification %#",localNotif);
NSString *theDisplaytext = [localNotif.userInfo valueForKey:#"someKey"];
[self presentWidget: theDisplaytext];
}
You need a way to start the UIViewController for the widget, I just created a mainScreenManager helper.
So on the widgetVC you have your "Snooze" and "OK" while the "Ignore" is just the ignoring of the notification itself.
Hope this gets you on an usable track...
ps I ported my app from Android to iPhone, that's why I used the name "widgetVC" for this screen. On Android it is implemented as a widget. Hope no iPhone lover feels offended :-)

ViewController doesn't show until I quit and relaunch app

I have just made my app universal by combining separate iPhone and iPad projects. Everything seems to be working but there is one major bug.
When the iPad app launches it just displays a black screen (presumably the window) and status bar. When I press the home button I suddenly see the SplitViewController as it disappears. When I open the app up again the SplitViewController is displayed.
I can't figure out why the controller only displays after I close and reopen the app. Any ideas?
(I don't have any idea what is causing this so if you need code samples from specific places let me know).
Thanks.
Edit:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Appirater appLaunched:YES];
// Registers this class as the delegate of the audio session.
[[AVAudioSession sharedInstance] setDelegate: self];
// Allow the app sound to continue to play when the screen is locked.
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
justOpened = YES;
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
{deleted}
} else {
[self.window addSubview:self.splitViewController.view];
[self.window makeKeyAndVisible];
CGRect rect = CGRectMake(-2, self.window.frame.size.height-29, self.window.frame.size.width+2, 29);
imgBar = [[UIImageView alloc] initWithFrame:rect];
imgBar.contentMode = UIViewContentModeScaleToFill;
imgBar.image = [UIImage imageNamed:#"wood_btm.png"];
imgBar.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin;
self.splitViewController.showsMasterInPortrait = YES;
self.splitViewController.title = #"Exams";
self.splitViewController.splitPosition=280;
}
return YES;
}
Update:
By messing around with the window's background color I discovered that for some reason it was at the top of the view hierarchy. I then made the window's background color clear and I could see the SplitViewController. Strangely I can also interact with it. So essentially I have solved the problem by making the window clear. This is obviously not the ideal solution though so if anyone can think of a cause let me know.
[self.window addSubview:self.splitViewController.view];
[self.window makeKeyAndVisible];
return YES;
should be at the end of -applicationDidFinishLaunching:WithOptions: method.
By messing around with the window's background color I discovered that for some reason it was at the top of the view hierarchy. I then made the window's background color clear and I could see the SplitViewController. Strangely I can also interact with it. So essentially I have solved the problem by making the window clear.

Creating a Time Based Reminder App in iPhone

I am working on time based reminder App. in which the user enter his reminder and time for the reminder. The problem is that how to continuously comparing the current time with the user defined time. Any sample code will greatly help. because i am stuck on this point.
Comparing the current time vs. the user defined one is not the right design pattern.
UIKit offers the NSLocalNotification object that is a more high-level abstraction for your task.
Below is a snip of code that create and schedule a local notification at the choosen time:
UILocalNotification *aNotification = [[UILocalNotification alloc] init];
aNotification.fireDate = [NSDate date];
aNotification.timeZone = [NSTimeZone defaultTimeZone];
aNotification.alertBody = #"Notification triggered";
aNotification.alertAction = #"Details";
/* if you wish to pass additional parameters and arguments, you can fill an info dictionary and set it as userInfo property */
//NSDictionary *infoDict = //fill it with a reference to an istance of NSDictionary;
//aNotification.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:aNotification];
[aNotification release];
Also, be sure to setup your AppDelegate to respond to local notifications, both at startup and during the normal runtime of the app (if you want to be notified even the application is in foreground):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UILocalNotification *aNotification = [launchOptions objectForKey: UIApplicationLaunchOptionsLocalNotificationKey];
if (aNotification) {
//if we're here, than we have a local notification. Add the code to display it to the user
}
//...
//your applicationDidFinishLaunchingWithOptions code goes here
//...
[self.window makeKeyAndVisible];
return YES;
}
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
//if we're here, than we have a local notification. Add the code to display it to the user
}
More details at the Apple Developer Documentation.
Why not use NSLocalNotification which you can set for a specified time, much like a calendar event. Alternatively you can add calendar events to the users calendar with EKEventKit
Tutorial for local notifications.
Tutorial for event kit.

CLLocationManager won't stop updating

Here is my code:
- (void) viewWillAppear:(BOOL)animated
{
// SETUP THE LOCATION MANAGER.
self.locManager = [[CLLocationManager alloc] init];
self.locManager.delegate = self;
[self.locManager startUpdatingLocation];
}
- (void) viewWillDisappear:(BOOL)animated
{
[self.locManager stopUpdatingLocation];
[self.locManager.delegate release];
}
When the View Controller exits the CLLocationManager arrow logo in the top right corner is still showing. This is both on iOS 4.3 and 5.0. Any explanation?
I believe the system indicates the location badge on any app that has used Core Location in last hour or so.
The purple arrow should disappear as soon as you call:
[self.locManager stopUpdatingLocation];
While allocating your locManager, you need not call self.locManager. That will bump up the retain count to 2. Instead use:
locManager = [[CLLocationManager alloc] init];
Also, put a breakpoint in your viewWillDisappear: method and make sure it does get called. Also, set the delegate to nil at the end.
After following these points, your code shall work.
The purple arrow is for Location Services and consumes battery heavily. Make sure the arrow disappears as soon as you call stopUpdatingLocation: