注意:需要遵循UINavigationControllerDelegate,并使本类成为代理
在返回页面实现下面方法:
- (void)navigationController:(UINavigationController*)navigationController willShowViewController:(UIViewController*)viewController animated:(BOOL)animated;
用法:
- (void)navigationController:(UINavigationController*)navigationController willShowViewController:(UIViewController*)viewController animated:(BOOL)animated{
if([[viewController class]isSubclassOfClass:[目标类 class]]) {
//在此执行刷新操作
}
//删除代理,防止该controller销毁后引起navigationController.delegate指向野指针造成崩溃
if(![[viewController class]isSubclassOfClass:[self class]]) {
self.navigationController.delegate=nil;
}
}
网友评论