简体   繁体   中英

XIB loads with black Screen from pushViewController

I have a Storyboard which loads a XIB with a TableView inside.

带有TableView的XIB

When the user selects a row from the TableView a new XIB should be loaded with the following method pushViewController:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    RecipeDetailViewController *recipeDetailViewController = [[RecipeDetailViewController alloc] init];
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    NSString *str = cell.textLabel.text;
    recipeDetailViewController.navTitle = str;

    // Pass the selected object to the new view controller.
    [self.navigationController pushViewController:recipeDetailViewController animated:YES];

}

The loaded new XIB should show the following View (with a button inside):

在此处输入图片说明

Instead it loads a black view like below:

在此处输入图片说明

I checked whether the view is connected to the viewcontroller. From my point of view everything is fine. In IB it the view is connected the File's Owner:

在此处输入图片说明

I solved it. All I had to do is to close XCode and reopen the project. After that all worked just fine!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM