Bra*_*n A 5 uinavigationcontroller ios
脚本
我有一个带导航控制器的应用程序.当导航控制器将另一个控制器推到堆栈上时,在屏幕的左上角显示后退按钮"<(最后一个视图控制器的标题)".
我需要的
我需要像(伪代码)......
-(void)detectedBackButtonWasPushed {
NSLog(@"Back Button Pressed");
//Do what I need done
}
Run Code Online (Sandbox Code Playgroud)
题
因为此按钮是由导航控制器创建的,而我没有在故事板中创建此按钮,所以如何将后退按钮"连接"到这样的方法?
我曾为Oleg尝试过的例子
-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"notification"];
if (viewController == vc) {
NSLog(@"BACK BUTTON PRESSED");
}
}
Run Code Online (Sandbox Code Playgroud)
这是我应该怎么做的?因为这不起作用.
用于 viewWillDisappear检测这一点。
-(void) viewWillDisappear:(BOOL)animated
{
if ([self.navigationController.viewControllers indexOfObject:self]==NSNotFound)
{
[self backButtonPressed];
[self.navigationController popViewControllerAnimated:NO];
}
[super viewWillDisappear:animated];
}
-(void)backButtonPressed
{
NSLog(@"YEA");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3969 次 |
| 最近记录: |