Commit 4a03ac18 authored by 汪洋's avatar 汪洋

优化initReferer

parent 8ffe8b37
......@@ -25,7 +25,14 @@
// 分present与navigation两种情况
UIViewController *me = (UIViewController *)self;
if (me.presentingViewController != nil) {
objc_setAssociatedObject(self, @selector(referer), me.presentingViewController.pageName, OBJC_ASSOCIATION_COPY);
// app全局只有一个navigation,发现此时用navigation.topViewController presentViewController时,最终使用的是navigation弹出的
// 所以此处要判断,如果是navigation弹出,最后还是要定位到topViewController
if ([me.presentingViewController isKindOfClass:[UINavigationController class]]) {
UIViewController *top = ((UINavigationController *)me.presentingViewController).topViewController;
objc_setAssociatedObject(self, @selector(referer), top.pageName, OBJC_ASSOCIATION_COPY);
} else {
objc_setAssociatedObject(self, @selector(referer), me.presentingViewController.pageName, OBJC_ASSOCIATION_COPY);
}
} else {
NSArray *navigationPool = ((UIViewController *)self).navigationController.viewControllers;
NSInteger refererIndex = navigationPool.count - 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment