导航栏后退按钮的iOS动作不起作用

时间:2015-12-14 16:56:37

标签: ios objective-c

我正在尝试向导航后退按钮添加一个功能,但它无法正常工作。以下是我的代码:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(removePinsOfMap:)];
    self.detailViewController = (DetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController];
}


- (void) removePinsOfMap: (UIBarButtonItem *)sender{
    NSLog(@"HI");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   // Dispose of any resources that can be recreated.
}

-(void) viewWillDisappear:(BOOL)animated {
    if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound) {
        // back button was pressed.  We know this is true because self is no longer
        // in the navigation stack.
    }
    [super viewWillDisappear:animated];
}

我不知道为什么它不会将“hi”记录到我的控制台

0 个答案:

没有答案