Search code examples
iosobjective-cxcodeuistoryboarduisplitviewcontroller

Xcode Storyboard - Items not appearing


I have aUIView in a Detail Scene in my storyboard and the strangest thing happens. When I try to add a simpleUILabel and then run my app, it does not appear. Soooo weird.

Here is a screenshot of my entire split view controller with the detail scene:

enter image description here

enter image description here

enter image description here

Here is my Segue code:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    if ([[segue identifier] isEqualToString:@"showDetail"]) {
        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        NSString *strPOIndex = [self.tableData[indexPath.row] valueForKey:@"Vendor"];
        LHContactsDetail *controller = (LHContactsDetail *)[[segue destinationViewController] topViewController];
        [controller setDetailItem:strPOIndex];
        controller.navigationItem.leftBarButtonItem = self.splitViewController.displayModeButtonItem;
        controller.navigationItem.leftItemsSupplementBackButton = YES;
    }

}

I am able to add items to the Master Scene Navigation Item. But the label I added to the Detail scene is not appearing when I run the app.

Any suggestions ?


Solution

  • Well, this kind of issue is easy to debug, and you should learn how to debug.

    Just enable view debugging in xcode, and leverage lldb, just print out the UILabel object and check if it is in its superview, and if the superview is in the window, etc.

    For example: if you know your label object is 0x12345678,

    on lldb, enter

    po [0x12345678 superview];

    If you see it is nil, then the UILabel is not added into superview

    If it has a valid UIView object, you might want to reapeat to see where's the problem. View debugging is quite a powerful tool to use for view debugging.