Creating nib view from UIBarButtonItem?

2020-05-08 11:50发布

So I've seen previous questions similar to this but they were of no help. I've read Apple's documentation too but I could not understand where I've gone wrong. AFAIK I did everything logically, but when I click on my done button on an UIToolbar overlay, the button can be pushed but it does not do anything. This obviously means it fails to acknowledge the written code. But how?

I want to bring up the .nib of "TableViewController" when a done button is clicked on my UIToolbar. But the below isn't allowing the click to bring up a new view. How do I rectify this? Please show me where I went wrong and what should be replaced and why.

//Here's the selector:
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:
    UIBarButtonSystemItemDone target:self  action:@selector(doneButtonPressed)];

Here's how I made my action.

-(void)doneButtonPressed {
    TableViewController *tableView = [[TableViewController alloc]
        initWithNibName:@"TableViewController" bundle:nil];
    tableView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:tableView animated:YES];
}

// Yet nothing happens when I click on my done button on my overlay. The button
// can be clicked, but nothing happens. Please shed any insight pleasee!

1条回答
何必那么认真
2楼-- · 2020-05-08 12:33

Did you create the UIToolbar into a nib file?

查看更多
登录 后发表回答