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

修正OCNavigatioinBar.m中关于titleView的bug;升级GMPhobos

parent 1e415d59
//
// UIViewController+Phobos.h
// Pods
//
// Created by wangyang on 16/7/12.
//
//
#import <UIKit/UIKit.h>
@interface UIViewController (Phobos)
/**
* @author 翟国钧, 16-02-24 17:02:22
*
* @brief 埋点的时候,有些埋点都需要业务id,比如DoctorId,针对那些只能在父类中埋点的业务,要在子类中设置当前id,然后在父类中取到
* 在一些详情页的分享和收藏的时候,由于分享、收藏的方法在basewebview里,所以,统一在里面做处理,但是需要在子类中把想要的参数传过去。包括:type(类型)、from(来自哪)、businessId(对应业务id)
* @since 5.9.1
*/
@property (nonatomic, copy, nonnull) NSString *businessId;
/**
* @author 翟国钧 in 16-02-25 19:02:32
*
* @brief 获取前一个页面的pageName
*
* @since 5.9.1
*/
@property (nonatomic, strong, readonly, nonnull) NSString *referer;
/**
* @author 翟国钧 in 16-02-25 19:02:32
*
* 埋点pv事件中当前页面的别名
* @since 5.9.1
*/
@property (nonatomic, copy, nonnull) NSString *pageName;
@end
//
// UIViewController+Phobos.m
// Pods
//
// Created by wangyang on 16/7/12.
//
//
#import "UIViewController+Phobos.h"
#import <objc/runtime.h>
@implementation UIViewController (Phobos)
/**
* @author 翟国钧, 16-03-01 15:03:24
*
* @brief 取当前导航栈中当前VC的上级VC,如果该VC存在,就获取他的pageName
*
* @return 前一页的pageName
*
* @since 5.9.1
*/
- (NSString *)referer
{
NSArray *navigationPool = self.navigationController.viewControllers;
NSInteger refererIndex = navigationPool.count - 2;
if (refererIndex < 0 ) {
return @"";
}
UIViewController *controller = navigationPool[refererIndex];
return controller.pageName == nil ? @"" : controller.pageName;
}
- (NSString *)pageName {
NSString *name = objc_getAssociatedObject(self, @selector(pageName));
return name == nil ? @"" : name;
}
- (void)setPageName:(NSString *)pageName {
objc_setAssociatedObject(self, @selector(pageName), pageName, OBJC_ASSOCIATION_COPY);
}
- (NSString *)businessId {
NSString *businessId = objc_getAssociatedObject(self, @selector(businessId));
return businessId == nil ? @"" : businessId;
}
- (void)setBusinessId:(NSString *)businessId {
objc_setAssociatedObject(self, @selector(businessId), businessId, OBJC_ASSOCIATION_COPY);
}
@end
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