0

I have a new view controller that gets instantiated from the app delegate when a push notification is received. In the view controller's header file, I have an NSDictionary created, and I set it the value of the dictionary to be the userInfo in the app delegate's didReceiveRemoteNotification.

The dictionary is being populated with the userInfo, but none of the labels are appearing. I know this because I logged it in the view controller. The problem, is that the view is completely blank.

I tried changing a bunch of things around, like using viewDidLoad, viewDidAppear, viewWillAppear, but none have helped.

Here is the code

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:NO];

    NSLog(@"VIEW DID Appear");
    NSLog(@"TDICTIONARY: %@", tDictionary);

    self.taskAddress.text = [tDictionary objectForKey:@"address"];
    NSLog(@"Address: %@", [tDictionary objectForKey:@"address"]);
    self.taskName.text = [tDictionary objectForKey:@"task"];
    NSLog(@"Name: %@", [tDictionary objectForKey:@"task"]);

    ...

I've been pulling my hair out trying to figure this out, so any help would be great appreciated!

Edit the following is the code that instantiates the view. I do not think this is the issue, because the dictionary is being passed to the view controller (I know this because I logged it from the view controller), but I very well could be wrong about that.

let storyboard = UIStoryboard(name: "Main", bundle: nil)

            self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
            self.window!.rootViewController = remoteViewController()

            let vc = storyboard.instantiateViewControllerWithIdentifier("remoteViewController") as remoteViewController

            vc.tDictionary = userInfo

            println("DICTIONARY \(vc.tDictionary)")
            self.window!.makeKeyAndVisible()
            println("VIEW CONTROLLER \(vc)")
            self.window!.rootViewController!.presentViewController(vc, animated: false, completion:
                {() -> Void in println("new view")
            })

Edit 2 I disconnected the labels and the labels with the text "label" show up on the view. When I reconnected them, they went blank again. Only more convinced now that this has to do with viewDidAppear.

madgrand
  • 121
  • 1
  • 8
  • 3
    Not enough information. You need to debug it. Set a breakpoint in viewWillAppear and see what's happening. Are the outlets non-nil? Is the dictionary non-nil? Does the dictionary contain data for the keys you've shown? Also post the code that is "programmatically instantiating" your view controller. Are you seeing the views in your view controller, but without contents, or is your entire UI missing? – Duncan C Feb 05 '15 at 01:54
  • Did you connect your outlets to the labels in IB? – Joel Feb 05 '15 at 02:16
  • What is the logging output? – i_am_jorf Feb 05 '15 at 02:35
  • As I said before, the dictionary contains the information. I know this because it is logged in the viewDidAppear. – madgrand Feb 05 '15 at 03:00
  • All of the outlets are connected, I've checked several times – madgrand Feb 05 '15 at 03:01
  • I just logged the labels, and got the same values as the dictionary. I am convinced that this has to do with viewDidAppear. The strange thing is, the navigation bar and the bar button that I have on the view are loading. – madgrand Feb 05 '15 at 03:14
  • Also, I made sure that auto layout displayed the labels in the preview screen, so that's not the issue – madgrand Feb 05 '15 at 03:30

0 Answers0