Uitableview ios6-如何使工具栏按钮在另一个视图控制器中执行操作

Uitableview ios6-如何使工具栏按钮在另一个视图控制器中执行操作,uitableview,ios6,uibarbuttonitem,Uitableview,Ios6,Uibarbuttonitem,我有一个带有添加按钮的UI工具栏。我想让它在从属viewController中触发一个操作。我被卡住了 工具栏的设置如下所示: TopViewController.h IBOutlet UIToolbar* toolbar; @property (retain, nonatomic) IBOutlet UIToolbar *homeButton; @property (retain, nonatomic) IBOutlet UIToolbar *addButton; - (IBAction)h

我有一个带有添加按钮的UI工具栏。我想让它在从属viewController中触发一个操作。我被卡住了

工具栏的设置如下所示:

TopViewController.h

IBOutlet UIToolbar* toolbar;
@property (retain, nonatomic) IBOutlet UIToolbar *homeButton;
@property (retain, nonatomic) IBOutlet UIToolbar *addButton;

- (IBAction)homePlease:(id)sender;
- (IBAction)addStuff:(id)sender;
TopViewController.m

@class ItemViewController;
#import "ItemViewController.h"

- (IBAction)homePlease:(id)sender {
    //NSLog(@"%s", __FUNCTION__);
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)addStuff:(id)sender {
    NSLog(@"%s", __FUNCTION__);
    [self.itemViewController insertNewObject:self]; <-----
}
主页按钮工作正常

addButton启动(我看到日志)。但没有其他事情发生。添加按钮连接到iAction

任何建议都是非常受欢迎的

似乎是正确的。必须在其显示视图控制器中设置按钮。我希望这能帮助别人

- (void)insertNewObject:(id)sender {
    //NSLog(@"%s", __FUNCTION__);

    AddItemViewController *addItem = [[AddItemViewController alloc] initWithNibName:@"AddItem-iPad" bundle:nil];


    // Create a new managed object context for the new item - set its persistent store coordinator
    // to the same as that from the fetched results controller's context.

    NSManagedObjectContext .......

    [self.addContext setPersistentStoreCoordinator:[[self.fetchedResultsController managedObjectContext] persistentStoreCoordinator]];

    addItem.item = (DDItem *)[NSEntityDescription insertNewObjectForEntityForName:@"Item" inManagedObjectContext:context];

    UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:addItem];
    nc.modalPresentationStyle = UIModalPresentationFormSheet;
    [self presentViewController:nc animated:YES completion:nil];

}