Commit 751f2b78 authored by licong's avatar licong

Merge branch 'master' of git.gengmei.cc:gengmeiios/GMBase

parents 4b811872 f0499e7b
# OS X
.DS_Store
# Xcode
build/
*.pbxuser
......
......@@ -357,7 +357,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
AD2DAA4386519D3497CC28DC /* [CP] Copy Pods Resources */ = {
......@@ -402,7 +402,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
......
......@@ -14,7 +14,7 @@ PODS:
- AFNetworking/Serialization (3.1.0)
- AFNetworking/UIKit (3.1.0):
- AFNetworking/NSURLSession
- GMBase (0.0.8):
- GMBase (0.0.13):
- GMNetService
- GMPhobos
- GMRefresh
......@@ -26,9 +26,9 @@ PODS:
- TMCache (~> 2.1.0)
- GMNetService (0.1.3):
- AFNetworking (= 3.1.0)
- GMPhobos (0.2.9):
- GMPhobos (0.2.18):
- GMCache (~> 0.1.0)
- GMRefresh (0.1.3):
- GMRefresh (0.1.4):
- MJRefresh (~> 3.1.0)
- JSONModel (1.2.0)
- Masonry (1.0.1)
......@@ -46,11 +46,11 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
GMBase: a2bc5ffc054605e22ae83a99268efc67a69aeac8
GMBase: 0f607b29178e5c89fdd6e01a58fafac454fbe1d6
GMCache: a7b06a2d8a5a1c7cf023055c631ba9a0cd7c39fc
GMNetService: 2eb74ed62512078e9f00bc7006227a93c2acdf32
GMPhobos: c9a93b2bc8c977820b249c9c615204133358cc09
GMRefresh: a37fb054e758805ec2a6f9b632cf3dc861bb3cf9
GMPhobos: ea037939d26853e09774fd7e399f0b34fc6107aa
GMRefresh: 8d6ef25dbd38c2687fee713cc520012d47c7261e
JSONModel: 12523685c4b623553ccf844bbbf7007624317b2c
Masonry: a1a931a0d08870ed8ae415a2ea5ea68ebcac77df
MBProgressHUD: 1569cf7ace17a8bac47aabfbb8580a49690386d1
......@@ -60,4 +60,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 9ce9038dd459ce1a2403f8111c792b3549ce8741
COCOAPODS: 1.0.1
COCOAPODS: 1.1.0.rc.2
......@@ -10,6 +10,9 @@
@interface Phobos : NSObject
@property (strong, nonatomic) UINavigationController *selectedNavigationController;
/**
* @brief 开启Phobos统计,默认以BATCH方式发送log.
*
......@@ -46,16 +49,18 @@
- (void)setUserId:(NSInteger)userId;
/*!
* @author zhaiguojun, 16-05-30
* @author zhaiguojun, 16-05-31
*
* @brief 用户当前的城市id
*
* @param currentCityId
*
* @since 0.2.5
* @since 0.2.7
*/
- (void)setCurrentCityId:(NSString *)currentCityId;
- (void)setGPS:(NSDictionary *)gps;
/**
* @brief 自定义事件,数量统计.
*
......@@ -88,14 +93,14 @@
*
* @since 0.0.8
*/
- (void)onPageStart:(NSString *)pageName businessId:(NSString *)businessId referer:(NSString *)refererPageName;
- (void)onPageStart:(NSString *)pageName businessId:(NSString *)businessId referer:(NSString *)refererPageName inTime:(NSString *)time;
/**
* @brief 当页面结束时的PV处理,在此方法中记录当前页面的停留时间和记录本次埋点事件
*
* @since 0.0.8
*/
- (void)onPageEnd;
- (void)onPageEnd:(NSString *)pageName businessId:(NSString *)businessId referer:(NSString *)refererPageName inTime:(NSString *)time;
/**
* @author 翟国钧, 16-03-08 11:03:45
......
......@@ -11,7 +11,7 @@
#import <AdSupport/AdSupport.h>
#import "PhobosUtil.h"
#import "PhobosConfig.h"
#import "UIViewController+Phobos.h"
static Phobos *sharedClient = nil;
static NSString *sdkVersion = @"110";
......@@ -25,14 +25,9 @@ static NSString *sdkVersion = @"110";
@property (strong, nonatomic) NSString *appVersion;
@property (assign, nonatomic) NSInteger userId;
@property (assign, nonatomic) BOOL logEnabled;
@property (strong, nonatomic) NSString *businessId;
@property (strong, nonatomic) NSString *sessionId;
@property (strong, nonatomic) NSString *pageName;
@property (strong, nonatomic) NSString *refererPageName;
@property (strong, nonatomic) NSString *pageEnterTime;
@property (strong, nonatomic) NSString *pageExitTime;
@property (strong, nonatomic) NSMutableDictionary *pageEnterParam;
@property (strong, nonatomic) NSString *lng;
@property (strong, nonatomic) NSString *lat;
@end
......@@ -58,6 +53,8 @@ static NSString *sdkVersion = @"110";
_channelId = channelId;
_logEnabled = NO;
_userId = 0;
_lat = @"";
_lng = @"";
_currentCityId = @"";
_appVersion = [self getAppVersion];
[self setupNotification];
......@@ -81,6 +78,17 @@ static NSString *sdkVersion = @"110";
_currentCityId = currentCityId;
}
- (void)setGPS:(NSDictionary *)gps {
@try {
NSString *lng = gps[@"lng"];
NSString *lat = gps[@"lat"];
_lng = lng;
_lat = lat;
} @catch (NSException *exception) {
phobosLog(exception);
}
}
- (void)handleEventAfterInit{
WMCacheService *cache = [WMCacheService sharedInstance];
......@@ -90,10 +98,22 @@ static NSString *sdkVersion = @"110";
/** 第一次打开APP埋点 **/
if (![cache fetchObjectAtDiskWithkey:PhobosHaveOpenApp]) {
[Phobos track:@"device_activated" attributes:@{} sendNow:YES];
[Phobos track:@"device_activated" attributes:@{} sendNow:NO];
[cache storeObjectAtDiskWithkey:PhobosHaveOpenApp object:PhobosHaveOpenApp];
}
}
- (UINavigationController *)selectedNavigationController{
if ([[UIApplication sharedApplication].keyWindow.rootViewController isKindOfClass:[UITabBarController class]]) {
UITabBarController *tabbar = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
UINavigationController *navigationController = (UINavigationController *)tabbar.selectedViewController;
return navigationController;
}else{
NSAssert(0, @"获取不到 selectedNavigationController %@", NSStringFromClass([UIApplication sharedApplication].keyWindow.rootViewController.class));
return nil;
}
}
#pragma mark - notification handler
/**
......@@ -142,6 +162,7 @@ static NSString *sdkVersion = @"110";
phobosLog(@"handleAppInForeground");
[self handleSessionStart];
[self fetchDataAndSend];
[self handlePVEventAppInForeground];
}
/**
......@@ -155,6 +176,7 @@ static NSString *sdkVersion = @"110";
phobosLog(@"handleAppInBackgound");
[self handleSessionOver];
[self fetchDataAndSend];
[self handlePVEventAppInBackgound];
}
/**
......@@ -177,6 +199,30 @@ static NSString *sdkVersion = @"110";
[cache removeObjectAtDiskWithkey:PhobosBeginTime];
}
/**
APP从后台到前台的时候,重新初始化pagename等信息
@author zhaiguojun 16-10-11 in (null)
*/
- (void)handlePVEventAppInForeground {
NSString *pageName = self.selectedNavigationController.visibleViewController.pageName;
NSString *businessId = self.selectedNavigationController.visibleViewController.businessId;
NSString *regerer = self.selectedNavigationController.visibleViewController.referer;
self.selectedNavigationController.visibleViewController.inTime = [self currentTime];
[self onPageStart:pageName businessId:businessId referer:regerer inTime:[self currentTime]];
}
/**
APP进到后台的时候,把当前pageview时间结束
@author zhaiguojun 16-10-11 in (null)
*/
- (void)handlePVEventAppInBackgound {
NSString *pageName = self.selectedNavigationController.visibleViewController.pageName;
NSString *businessId = self.selectedNavigationController.visibleViewController.businessId;
NSString *referer = self.selectedNavigationController.visibleViewController.referer;
NSString *inTime = self.selectedNavigationController.visibleViewController.inTime;
[self onPageEnd:pageName businessId:businessId referer:referer inTime:inTime];
}
#pragma mark - track event handler
+ (void)track:(NSString *)eventId{
......@@ -188,7 +234,7 @@ static NSString *sdkVersion = @"110";
NSArray *array = [[WMCacheService sharedInstance] fetchObjectAtDiskWithkey:PhobosCacheKey];
//超过一定数量的话,统一发送一次
if (array.count > PhobosShardCount) {
[sharedClient sendArray:array];
[sharedClient sendArray:array cleanCacheRightNow:YES];
}
}
......@@ -196,7 +242,8 @@ static NSString *sdkVersion = @"110";
NSDictionary *dict = [sharedClient prepareDictionaryForEvent:eventId attributes:attributes];
if (sendNow) {
NSArray *array = @[dict];
[sharedClient sendArray:array];
// 实时发送的埋点,不能立即清楚缓存
[sharedClient sendArray:array cleanCacheRightNow:NO];
}else{
[sharedClient save:dict];
}
......@@ -226,26 +273,25 @@ static NSString *sdkVersion = @"110";
}
#pragma mark - pv
- (void)onPageStart:(NSString *)pageName businessId:(NSString *)businessId referer:(NSString *)refererPageName{
_pageEnterParam = [NSMutableDictionary dictionaryWithObjectsAndKeys:
pageName?:@"",@"page_name",
self.businessId?:@"",@"business_id",
self.refererPageName?:@"",@"referer",
[self currentTime],@"in",nil];
- (void)onPageStart:(NSString *)pageName businessId:(NSString *)businessId referer:(NSString *)refererPageName inTime:(NSString *)time{
//目前来说,变成了空方法,其主要功能是给当前VC的属性赋值,下个版本优化,挪到UIViewController+Phobos里去
}
- (void)onPageEnd{
- (void)onPageEnd:(NSString *)pageName businessId:(NSString *)businessId referer:(NSString *)refererPageName inTime:(NSString *)time{
if (![self isNonEmpty:pageName]) {
return;
}
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
@try {
[dict setObject:[self currentTime] forKey:@"out"];
[dict setObject:@([_pageEnterParam[@"in"] doubleValue])?:@"" forKey:@"in"];
[dict setObject:_pageEnterParam[@"page_name"]?:@"" forKey:@"page_name"];
[dict setObject:_pageEnterParam[@"business_id"]?:@"" forKey:@"business_id"];
[dict setObject:_pageEnterParam[@"referer"]?:@"" forKey:@"referer"];
[dict setObject:time?:@"" forKey:@"in"];
[dict setObject:pageName forKey:@"page_name"];
[dict setObject:businessId?:@"" forKey:@"business_id"];
[dict setObject:refererPageName?:@"" forKey:@"referer"];
[dict setObject:@(0) forKey:@"fake"];
[Phobos track:@"page_view" attributes:dict];
[_pageEnterParam removeAllObjects];
}
@catch (NSException *exception) {
phobosLog(exception);
......@@ -263,7 +309,6 @@ static NSString *sdkVersion = @"110";
[dict setObject:@(1) forKey:@"fake"];
[Phobos track:@"page_view" attributes:dict];
[_pageEnterParam removeAllObjects];
}
@catch (NSException *exception) {
phobosLog(exception);
......@@ -283,7 +328,11 @@ static NSString *sdkVersion = @"110";
NSString *currentTime = [self currentTime];
NSMutableDictionary *deviceParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString],@"device_id",
@"ios",@"device_type",nil];
[[[UIDevice currentDevice] identifierForVendor] UUIDString],@"idfv",
@"ios",@"device_type",
@"Apple",@"manufacturer",
_lat,@"lat",
_lng,@"lng",nil];
NSMutableDictionary *appParams = [NSMutableDictionary dictionaryWithObjectsAndKeys:
self.appName, @"name",
self.appVersion, @"version",
......@@ -334,18 +383,18 @@ static NSString *sdkVersion = @"110";
- (void)fetchDataAndSend{
NSArray *paramsArray = [[WMCacheService sharedInstance] fetchObjectAtDiskWithkey:PhobosCacheKey];
if (paramsArray.count>0) {
[self sendArray:paramsArray];
[self sendArray:paramsArray cleanCacheRightNow:YES];
}
}
/**
* @brief 发送数组
*
* @param array
*
* @since 0.0.1
向Mars发送埋点数据,如果是实时发送的,http请求成功之后,不清楚已有的缓存数据。
针对普通埋点数据,发送成功之后,立即删除本地的缓存。
@author zhaiguojun 16-10-17 in (null)
@param array 参数
@param now 是否立即清楚缓存
*/
- (void)sendArray:(NSArray *)array {
- (void)sendArray:(NSArray *)array cleanCacheRightNow:(BOOL)clean {
if (_logEnabled) {
phobosLog([NSString stringWithFormat:@"array prepare to fly --✈: %@",array]);
}
......@@ -355,7 +404,9 @@ static NSString *sdkVersion = @"110";
if (compressedData) {
[PhobosUtil sendData:compressedData success:^(NSInteger code) {
phobosLog(@"✈ ---------- ✈ data arrived Mars");
[[WMCacheService sharedInstance] removeObjectAtDiskWithkey:PhobosCacheKey];
if (clean) {
[[WMCacheService sharedInstance] removeObjectAtDiskWithkey:PhobosCacheKey];
}
}];
}
}
......@@ -430,5 +481,4 @@ static NSString *sdkVersion = @"110";
}
}
@end
......@@ -25,7 +25,7 @@
*
* @since 5.9.1
*/
@property (nonatomic, strong, readonly, nonnull) NSString *referer;
@property (nonatomic, copy, nonnull) NSString *referer;
/**
* @author 翟国钧 in 16-02-25 19:02:32
......@@ -34,4 +34,11 @@
* @since 5.9.1
*/
@property (nonatomic, copy, nonnull) NSString *pageName;
/**
当前VC.view 显示的时候的时间戳
@author zhaiguojun 16-10-12 in (null)
*/
@property (nonatomic, copy, nonnull) NSString *inTime;
@end
......@@ -19,16 +19,21 @@
*
* @since 5.9.1
*/
- (NSString *)referer
{
- (void)setReferer:(NSString *)referer {
NSArray *navigationPool = self.navigationController.viewControllers;
NSInteger refererIndex = navigationPool.count - 2;
if (refererIndex < 0 ) {
return @"";
return ;
}
UIViewController *controller = navigationPool[refererIndex];
return controller.pageName == nil ? @"" : controller.pageName;
objc_setAssociatedObject(self, @selector(referer), controller.pageName, OBJC_ASSOCIATION_COPY);
}
- (NSString *)referer
{
NSString *referer = objc_getAssociatedObject(self, @selector(referer));
return referer == nil ? @"" : referer;
}
- (NSString *)pageName {
......@@ -48,4 +53,14 @@
- (void)setBusinessId:(NSString *)businessId {
objc_setAssociatedObject(self, @selector(businessId), businessId, OBJC_ASSOCIATION_COPY);
}
- (void)setInTime:(NSString *)inTime {
objc_setAssociatedObject(self, @selector(inTime), inTime, OBJC_ASSOCIATION_COPY);
}
- (NSString *)inTime {
NSString *inTime = objc_getAssociatedObject(self, @selector(inTime));
return inTime;
}
@end
......@@ -76,9 +76,10 @@
// pullingPercent 超过 1 时,位置固定
self.gifView.hidden = NO;
CGFloat translation = self.mj_h * 1 / 2;
CGFloat scale = MIN(1.0, pullingPercent);
_prepareImageView.transform = CGAffineTransformMakeTranslation(0, -translation);
_prepareImageView.transform = CGAffineTransformScale(_prepareImageView.transform, pullingPercent, pullingPercent);
_prepareImageView.transform = CGAffineTransformScale(_prepareImageView.transform, scale, scale);
}
}
}
......
{
"name": "GMBase",
"version": "0.0.8",
"version": "0.0.13",
"summary": "更美iOS APP 的 Objective-C 基础Pod库",
"homepage": "http://git.gengmei.cc/gengmeiios/GMBase",
"license": "仅限北京更美互动信息科技有限公司内部使用",
......@@ -8,8 +8,8 @@
"wangyang": "wangyang@gmei.com"
},
"source": {
"git": "http://git.gengmei.cc/gengmeiios/GMBase.git",
"tag": "0.0.8"
"git": "git@git.gengmei.cc:gengmeiios/GMBase.git",
"tag": "0.0.13"
},
"platforms": {
"ios": "8.0"
......
......@@ -14,7 +14,7 @@ PODS:
- AFNetworking/Serialization (3.1.0)
- AFNetworking/UIKit (3.1.0):
- AFNetworking/NSURLSession
- GMBase (0.0.8):
- GMBase (0.0.13):
- GMNetService
- GMPhobos
- GMRefresh
......@@ -26,9 +26,9 @@ PODS:
- TMCache (~> 2.1.0)
- GMNetService (0.1.3):
- AFNetworking (= 3.1.0)
- GMPhobos (0.2.9):
- GMPhobos (0.2.18):
- GMCache (~> 0.1.0)
- GMRefresh (0.1.3):
- GMRefresh (0.1.4):
- MJRefresh (~> 3.1.0)
- JSONModel (1.2.0)
- Masonry (1.0.1)
......@@ -46,11 +46,11 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
GMBase: a2bc5ffc054605e22ae83a99268efc67a69aeac8
GMBase: 0f607b29178e5c89fdd6e01a58fafac454fbe1d6
GMCache: a7b06a2d8a5a1c7cf023055c631ba9a0cd7c39fc
GMNetService: 2eb74ed62512078e9f00bc7006227a93c2acdf32
GMPhobos: c9a93b2bc8c977820b249c9c615204133358cc09
GMRefresh: a37fb054e758805ec2a6f9b632cf3dc861bb3cf9
GMPhobos: ea037939d26853e09774fd7e399f0b34fc6107aa
GMRefresh: 8d6ef25dbd38c2687fee713cc520012d47c7261e
JSONModel: 12523685c4b623553ccf844bbbf7007624317b2c
Masonry: a1a931a0d08870ed8ae415a2ea5ea68ebcac77df
MBProgressHUD: 1569cf7ace17a8bac47aabfbb8580a49690386d1
......@@ -60,4 +60,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 9ce9038dd459ce1a2403f8111c792b3549ce8741
COCOAPODS: 1.0.1
COCOAPODS: 1.1.0.rc.2
This diff is collapsed.
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.0.8</string>
<string>0.0.13</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.2.9</string>
<string>0.2.18</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.1.3</string>
<string>0.1.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -13,7 +13,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>0.1.3</string>
<string>0.1.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -34,6 +34,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>AFNetworking</string>
<key>Type</key>
......@@ -61,6 +63,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>License</key>
<string>&#20165;&#38480;&#21271;&#20140;&#26356;&#32654;&#20114;&#21160;&#20449;&#24687;&#31185;&#25216;&#26377;&#38480;&#20844;&#21496;&#20869;&#37096;&#20351;&#29992;</string>
<key>Title</key>
<string>GMBase</string>
<key>Type</key>
......@@ -88,6 +92,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>GMCache</string>
<key>Type</key>
......@@ -115,6 +121,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>GMNetService</string>
<key>Type</key>
......@@ -142,6 +150,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>GMPhobos</string>
<key>Type</key>
......@@ -169,6 +179,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>GMRefresh</string>
<key>Type</key>
......@@ -200,6 +212,8 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The MIT License in plain English: http://www.touch-code-magazine.com/JSONModel/MITLicense
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>JSONModel</string>
<key>Type</key>
......@@ -226,6 +240,8 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>MBProgressHUD</string>
<key>Type</key>
......@@ -253,6 +269,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>MJRefresh</string>
<key>Type</key>
......@@ -279,6 +297,8 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>Masonry</string>
<key>Type</key>
......@@ -488,6 +508,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
</string>
<key>License</key>
<string>Apache 2.0</string>
<key>Title</key>
<string>TMCache</string>
<key>Type</key>
......@@ -518,6 +540,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</string>
<key>License</key>
<string>MIT</string>
<key>Title</key>
<string>UITableView+FDTemplateLayoutCell</string>
<key>Type</key>
......
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO
FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking" "$PODS_CONFIGURATION_BUILD_DIR/GMBase" "$PODS_CONFIGURATION_BUILD_DIR/GMCache" "$PODS_CONFIGURATION_BUILD_DIR/GMNetService" "$PODS_CONFIGURATION_BUILD_DIR/GMPhobos" "$PODS_CONFIGURATION_BUILD_DIR/GMRefresh" "$PODS_CONFIGURATION_BUILD_DIR/JSONModel" "$PODS_CONFIGURATION_BUILD_DIR/MBProgressHUD" "$PODS_CONFIGURATION_BUILD_DIR/MJRefresh" "$PODS_CONFIGURATION_BUILD_DIR/Masonry" "$PODS_CONFIGURATION_BUILD_DIR/TMCache" "$PODS_CONFIGURATION_BUILD_DIR/UITableView+FDTemplateLayoutCell"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
......
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO
FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking" "$PODS_CONFIGURATION_BUILD_DIR/GMBase" "$PODS_CONFIGURATION_BUILD_DIR/GMCache" "$PODS_CONFIGURATION_BUILD_DIR/GMNetService" "$PODS_CONFIGURATION_BUILD_DIR/GMPhobos" "$PODS_CONFIGURATION_BUILD_DIR/GMRefresh" "$PODS_CONFIGURATION_BUILD_DIR/JSONModel" "$PODS_CONFIGURATION_BUILD_DIR/MBProgressHUD" "$PODS_CONFIGURATION_BUILD_DIR/MJRefresh" "$PODS_CONFIGURATION_BUILD_DIR/Masonry" "$PODS_CONFIGURATION_BUILD_DIR/TMCache" "$PODS_CONFIGURATION_BUILD_DIR/UITableView+FDTemplateLayoutCell"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
......
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO
FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking" "$PODS_CONFIGURATION_BUILD_DIR/GMBase" "$PODS_CONFIGURATION_BUILD_DIR/GMCache" "$PODS_CONFIGURATION_BUILD_DIR/GMNetService" "$PODS_CONFIGURATION_BUILD_DIR/GMPhobos" "$PODS_CONFIGURATION_BUILD_DIR/GMRefresh" "$PODS_CONFIGURATION_BUILD_DIR/JSONModel" "$PODS_CONFIGURATION_BUILD_DIR/MBProgressHUD" "$PODS_CONFIGURATION_BUILD_DIR/MJRefresh" "$PODS_CONFIGURATION_BUILD_DIR/Masonry" "$PODS_CONFIGURATION_BUILD_DIR/TMCache" "$PODS_CONFIGURATION_BUILD_DIR/UITableView+FDTemplateLayoutCell"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
......
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = NO
FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/AFNetworking" "$PODS_CONFIGURATION_BUILD_DIR/GMBase" "$PODS_CONFIGURATION_BUILD_DIR/GMCache" "$PODS_CONFIGURATION_BUILD_DIR/GMNetService" "$PODS_CONFIGURATION_BUILD_DIR/GMPhobos" "$PODS_CONFIGURATION_BUILD_DIR/GMRefresh" "$PODS_CONFIGURATION_BUILD_DIR/JSONModel" "$PODS_CONFIGURATION_BUILD_DIR/MBProgressHUD" "$PODS_CONFIGURATION_BUILD_DIR/MJRefresh" "$PODS_CONFIGURATION_BUILD_DIR/Masonry" "$PODS_CONFIGURATION_BUILD_DIR/TMCache" "$PODS_CONFIGURATION_BUILD_DIR/UITableView+FDTemplateLayoutCell"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
......
Pod::Spec.new do |s|
s.name = 'GMBase'
s.version = '0.0.9'
s.version = '0.0.14'
s.summary = '更美iOS APP 的 Objective-C 基础Pod库'
s.homepage = 'http://git.gengmei.cc/gengmeiios/GMBase'
s.license = '仅限北京更美互动信息科技有限公司内部使用'
......
......@@ -44,7 +44,9 @@
make.height.offset(1/[UIScreen mainScreen].scale);
}];
_itemView = [[UIView alloc] initWithFrame:CGRectMake(0, 20, [UIScreen mainScreen].bounds.size.width, 44)];
_titleLabel = [[UILabel alloc] initWithFrame:_itemView.bounds];
CGFloat titleW = [UIScreen mainScreen].bounds.size.width - 80;
_titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 0, titleW, 44)];
_titleLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
_titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_titleLabel.textAlignment = NSTextAlignmentCenter;
_titleLabel.backgroundColor = [UIColor clearColor];
......
......@@ -8,7 +8,7 @@
#import "WMBaseViewController.h"
#import "GMBaseUtil.h"
#import <GMPhobos/UIViewController+Phobos.h>
@interface WMBaseViewController () {
}
......@@ -92,7 +92,9 @@
// 导航栏隐藏在 viewWillAppear 里控制的原因是在viewDidLoad时,有可能 navigationController 与 self 并没有关系
self.navigationController.navigationBarHidden = YES;
[[Phobos sharedClient] onPageStart:self.pageName businessId:self.businessId referer:[self referer]];
[self setUpInTime];
[self setReferer:nil];
[[Phobos sharedClient] onPageStart:self.pageName businessId:self.businessId referer:self.referer inTime:self.inTime];
}
- (void)viewWillDisappear:(BOOL)animated
......@@ -105,7 +107,7 @@
}
if (self.pageName.length > 0) {
[[Phobos sharedClient] onPageEnd];
[[Phobos sharedClient] onPageEnd:self.pageName businessId:self.businessId referer:self.referer inTime:self.inTime];
}
}
......@@ -113,6 +115,12 @@
return UIStatusBarStyleDefault;
}
- (void)setUpInTime {
NSDate *date = [NSDate date];
NSTimeInterval interval = [date timeIntervalSince1970];
NSString *timeIntervalStr = [NSString stringWithFormat:@"%ld",(long)interval];
self.inTime = timeIntervalStr;
}
#pragma mark - 导航
- (void)customNavigationBar {
_navigationBar = [[OCNavigatioinBar alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 64)];
......
......@@ -8,10 +8,5 @@
#import <UIKit/UIKit.h>
/**
* @author wangyang
*
* 内部所有代码都是在处理自定义后退按键时,滑动后退(即interactivePopGestureRecognizer)不好使的问题
*/
@interface WMNavigationController : UINavigationController
@end
\ No newline at end of file
@end
......@@ -7,127 +7,13 @@
//
#import "WMNavigationController.h"
#import <objc/runtime.h>
@interface WMNavigationController () <UINavigationControllerDelegate, UIGestureRecognizerDelegate>
/// A Boolean value indicating whether navigation controller is currently pushing a new view controller on the stack.
@property (nonatomic, getter = isDuringPushAnimation) BOOL duringPushAnimation;
/// A real delegate of the class. `delegate` property is used only for keeping an internal state during
/// animations – we need to know when the animation ended, and that info is available only
/// from `navigationController:didShowViewController:animated:`.
@property (weak, nonatomic) id<UINavigationControllerDelegate> realDelegate;
@end
@implementation WMNavigationController
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationBarHidden = YES;
// 处理使用leftBarButton作为返回时,interactivePopGestureRecognizer不好使的问题
if (!self.delegate) {
self.delegate = self;
}
self.interactivePopGestureRecognizer.delegate = self;
// 这样在push时,view不会在导航栏上显示一黑色。尤其是在导航栏为透明时能看到
self.view.backgroundColor = [UIColor whiteColor];
}
- (void)dealloc
{
self.delegate = nil;
self.interactivePopGestureRecognizer.delegate = nil;
}
- (void)setDelegate:(id<UINavigationControllerDelegate>)delegate
{
[super setDelegate:delegate ? self : nil];
self.realDelegate = delegate != self ? delegate : nil;
}
- (void)pushViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
if (self.duringPushAnimation) {
return;
}
if (animated) {
self.duringPushAnimation = YES;
}
[super pushViewController:viewController animated:animated];
}
#pragma mark UINavigationControllerDelegate
- (void)navigationController:(UINavigationController *)navigationController
didShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
NSCAssert(self.interactivePopGestureRecognizer.delegate == self, @"WMNavigationController won't work correctly if you change interactivePopGestureRecognizer's delegate.");
self.duringPushAnimation = NO;
if ([self.realDelegate respondsToSelector:_cmd]) {
[self.realDelegate navigationController:navigationController didShowViewController:viewController animated:animated];
}
}
- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController animationControllerForOperation:(UINavigationControllerOperation)operation fromViewController:(UIViewController*)fromVC toViewController:(UIViewController*)toVC
{
if ([self.realDelegate respondsToSelector:_cmd]) {
return [self.realDelegate navigationController:navigationController animationControllerForOperation:operation fromViewController:fromVC toViewController:toVC];
}
return nil;
}
- (id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController*)navigationController interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>)animationController
{
if ([self.realDelegate respondsToSelector:_cmd]) {
return [self.realDelegate navigationController:navigationController interactionControllerForAnimationController:animationController];
}
return nil;
}
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer == self.interactivePopGestureRecognizer) {
// Disable pop gesture in two situations:
// 1) when the pop animation is in progress
// 2) when user swipes quickly a couple of times and animations don't have time to be performed
return [self.viewControllers count] > 1 && !self.isDuringPushAnimation;
} else {
// default value
return YES;
}
}
#pragma mark - Method Forward
// Thanks for the idea goes to: https://github.com/steipete/PSPDFTextView/blob/ee9ce04ad04217efe0bc84d67f3895a34252d37c/PSPDFTextView/PSPDFTextView.m#L148-164
- (BOOL)respondsToSelector:(SEL)s
{
return [super respondsToSelector:s] || [self.realDelegate respondsToSelector:s];
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)s
{
return [super methodSignatureForSelector:s] ?: [(id)self.realDelegate methodSignatureForSelector:s];
}
- (void)forwardInvocation:(NSInvocation *)invocation
{
id delegate = self.realDelegate;
if ([delegate respondsToSelector:invocation.selector]) {
[invocation invokeWithTarget:delegate];
}
}
@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