Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6.1 : Snapshotting a view that has not been rendered

I'm using storyboard for my sample project. The architecture is Login View Controller and Home PageView controller. User clicks on button in Home PageView controller to start local notification.

-(IBAction)startLocalNotification {  // Bind this method to UIButton action
    NSLog(@"startLocalNotification");

    UILocalNotification *notification = [[UILocalNotification alloc] init];
    notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:7];
    notification.alertBody = @"This is local notification!";
    notification.timeZone = [NSTimeZone defaultTimeZone];
    notification.soundName = UILocalNotificationDefaultSoundName;
    notification.applicationIconBadgeNumber = 10;

    [[UIApplication sharedApplication] scheduleLocalNotification:notification];
}

This code goes in AppDelegate file :

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.

    if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){

        [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
    }

    [launchOptions valueForKey:UIApplicationLaunchOptionsLocalNotificationKey];
    // Override point for customization after application launch.

    return YES;
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
 [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
     NSLog(@"didReceiveLocalNotification");
}

Now after pushing app to background state I'm getting below message in console but local notification is working fine as expected.

Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.

What this message is related to?

like image 741
Jayprakash Dubey Avatar asked Feb 11 '15 12:02

Jayprakash Dubey


1 Answers

I have what I believe could just about stand up as an 'answer'... And that is that there's almost certainly nothing wrong, but maybe a problem with iOS (8.1.3/8.2). As far as I can tell, it's innocuous.

I played around with this and found that it was related to UITextField/Keyboard.

So a single view app with just a text field, follow the steps below (only tried on iPad):

  1. Build and run
  2. Put focus in text field
  3. Close keyboard (it should have opened)
  4. Click home button (app enters background)
  5. Return to app
  6. Click home button (app enters background)
  7. Observe log output.

Here's a sample project: https://github.com/duttski/TestForStrangeSnapshotMessage .

Filed as a bug and trying to get some information through the dev forums too.

UPDATE: I think this may be fixed in later versions. But I haven't tested it. After speaking on the dev forums I was told that this isn't something to worry about.

like image 98
button Avatar answered Oct 21 '22 04:10

button