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?


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):

  • Build and run
  • Put focus in text field
  • Close keyboard (it should have opened)
  • Click home button (app enters background)
  • Return to app
  • Click home button (app enters background)
  • 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.

    链接地址: http://www.djcxy.com/p/24976.html

    上一篇: Android NFC读取ISO15693 RFID标签

    下一篇: Xcode 6.1:快照未渲染的视图