新建文件如下
UINavigationController+PushSafe.h
//
// UINavigationController+PushSafe.h
// Medical
//
// Created by chenguibang on 2017/3/21.
// Copyright © 2017年 chenguibang. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UINavigationController(PushSafe)
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated safe:(BOOL)safe;
@end
UINavigationController+PushSafe.h
//
// UINavigationController+PushSafe.m
// Medical
//
// Created by chenguibang on 2017/3/21.
// Copyright © 2017年 chenguibang. All rights reserved.
//
#import "UINavigationController+PushSafe.h"
@implementation UINavigationController(PushSafe)
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated safe:(BOOL)safe{
if ([[self.viewControllers lastObject] isKindOfClass:viewController.class]&&safe) {
return ;
}
[self pushViewController:viewController animated:animated];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
使用方法
[self.navigationController pushViewController:chatController animated:YES safe:YES];
网友评论