0

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. Btw, the uitoolbar has no nib, it's an overlay on the imagepickercontroller(camera mode).

-(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 nothing happens. Please shed any insight pleasee!
Andrew Laeddis
  • 135
  • 1
  • 2
  • 8
  • My suggestion in your other post still stands: http://stackoverflow.com/questions/11712784/creating-nib-view-from-uibatbuttonitem#comment15538002_11712784 – Rob Jul 30 '12 at 00:19
  • Could you provide some context for the first block of code where you create the `doneButton`? – oltman Jul 30 '12 at 00:19
  • can you print some log message to track if the control really reaches the 'doneButtonPressed' method? – Obaid Maroof Jul 30 '12 at 00:20

1 Answers1

0

This may not actually be the problem, but if the code your using above is how you're dismissing your Modal view controller it is incorrect. Other than possible improper usage I don't see any problems.

Use what you're using to present the Modal view controller, then to dismiss it use this:

[self dismissModalViewControllerAnimated:YES];
Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
  • 1
    I agree with your intuition here: It's completely backwards to have a button labeled "done" to take you to another view, which, when you dismiss that one, it will just bring you back to the same view with the same "done" button you had before! "Done" should be dismissing views, not taking you to new ones (which is what your solution suggests). If anything, if you really want to bring up another view, the button should be labeled "next" or something like that. But it doesn't explain why he's not seeing his `TableViewController`. – Rob Jul 30 '12 at 02:42