Julian Ezequiel
Julian Ezequiel

Reputation: 183

pushViewController lead to black screen, NO STORYBOARD

I see all the other solutions and nothing works for me. When I initiate the application, it works fine, but when I click a table item and push a ViewController, the screen goes black, and keeps black forever. Here is my code:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];

    ToDoItemViewController *itemViewController = [[ToDoItemViewController alloc] initWithNibName:@"ToDoItemViewController" bundle:[NSBundle mainBundle]];
    ToDoItem *itemSelected = [[self toDoItems] objectAtIndex:indexPath.row];

    itemViewController.toDoItem = itemSelected;
    itemViewController.delegate = self;

    [self.navigationController pushViewController:itemViewController animated:YES];
}

The name of the Nib is ok, and the ToDoItemViewController:

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {

    }
    return self;
}

Thanks in advance,

Remember, I DON'T USE STORYBOARDS and I want to keep that

EDIT

Here is how I launch my first ViewController

ListadoViewController *listadoViewController = [[ListadoViewController alloc] initWithNibName:@"ListadoViewController" bundle:nil];
        CustomNavigationController *navCtrl = [[CustomNavigationController alloc] initWithRootViewController:listadoViewController];
        self.window.rootViewController = navCtrl;

Upvotes: 0

Views: 493

Answers (1)

Julian Ezequiel
Julian Ezequiel

Reputation: 183

I resolved it. The problem was that I implement the method "loadView", but I didn't know that that method is implemented by iOS, so I was not calling the super and it wasn't drawing anything.

Thanks all for your responses.

Upvotes: 1

Related Questions