How to give barbuttonitem action?

I want to output the .nib "TableViewController" when the "Finish" button is clicked on my UIToolBar. But below is not allowed to click to open a new view. How to fix this? Please show me where I did wrong and what needs to be replaced and why.

//Here the selector in my overlay. 
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:
UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed)];

//Here how I made my action. Btw, the uitoolbar has no nib, it an overlay on the
//(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. And I've made sure
//   i've imported .h frameworks correctly too.

Suppose you have to pull the tip out of the barbuttonitem, which is on the overlay of the UItoolbar. How do you do this?

I was told that for proper operation I should add [barButtonItem addTarget: self action: @selector (doneButtonPressed) forControlEvents: UIControlEventTouchUpInside] ;,

But if I add it, I get the following:

UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:
UIBarButtonSystemItemDone addTarget:self action:@selector(doneButtonPressed)
forControlEvents:UIControlEventTouchUpInside];

"instance method" - initWithBarButtonSystemItem: target: action: forControlEvents: 'not found ( -' id ') "

, , , , .

+5
3

XCode 4, Ctrl + BarButtonItem .h , IB.

+5

A UIBarButtonItem UIControlEventTouchUpInside, . Xcode , :

UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed)];

, forControlEvents:.

+1

:

UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed:)];

-(void)doneButtonPressed:(id)sender
{
}

, ( UIBarButtonItem)

Second, set a breakpoint in your doneButtonPressed function. If, for example, the tableView becomes zero, then you will not see anything. that is, there may be a problem creating an instance of this view controller.

+1
source

All Articles