Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VirtualCard-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
APP
VirtualCard-iOS
Commits
b703cda2
Commit
b703cda2
authored
May 22, 2020
by
guanghui.shi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
弹窗逻辑修改
parent
33397f25
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
270 additions
and
92 deletions
+270
-92
QGActivityPopManager.h
...es/Card/Function/QGActivityManager/QGActivityPopManager.h
+5
-4
QGActivityPopManager.m
...es/Card/Function/QGActivityManager/QGActivityPopManager.m
+194
-75
QGActivityPopView.h
...asses/Card/Function/QGActivityManager/QGActivityPopView.h
+3
-0
QGActivityPopView.m
...asses/Card/Function/QGActivityManager/QGActivityPopView.m
+8
-1
QGCardViewController.m
...ard/Function/QGCard/ViewController/QGCardViewController.m
+7
-7
QGCashbackViewController.m
...nction/QGProfit/ViewController/QGCashbackViewController.m
+1
-1
QGMallContainerViewController.m
...llHomePage/ViewController/QGMallContainerViewController.m
+1
-1
QGQuotaManagerViewController.m
...uotaManager/ViewController/QGQuotaManagerViewController.m
+1
-1
QGNewUserCenterViewController.m
...serCenter/ViewConntroller/QGNewUserCenterViewController.m
+1
-1
SystemManager.m
VirtualPayment/VirtualPayment/QGUtils/QGTool/SystemManager.m
+49
-1
No files found.
VirtualPayment/VirtualPayment/QGClasses/Card/Function/QGActivityManager/QGActivityPopManager.h
View file @
b703cda2
...
...
@@ -26,10 +26,11 @@ typedef NS_ENUM(NSInteger,QGActivityPosition)
/// 便利构造器
+
(
instancetype
)
shareInstance
;
/// 展示某个位置的活动弹窗
/// @param position 位置
/// @param controller 承载弹窗的父控制器
-
(
void
)
showActivitiesAtPosition
:(
QGActivityPosition
)
position
inController
:(
UIViewController
*
)
controller
;
/// 因为弹窗会发生变化,去掉这个初始化
///// 展示某个位置的活动弹窗
///// @param position 位置
///// @param controller 承载弹窗的父控制器
//- (void)showActivitiesAtPosition:(QGActivityPosition)position inController:(UIViewController *)controller;
/// 如果包含多个弹窗,在ViewController的viewDidAppear调用此方法
-
(
void
)
viewDidAppearAtPosition
:(
QGActivityPosition
)
position
inController
:(
UIViewController
*
)
controller
;
...
...
VirtualPayment/VirtualPayment/QGClasses/Card/Function/QGActivityManager/QGActivityPopManager.m
View file @
b703cda2
...
...
@@ -24,6 +24,19 @@
#import "QGUserInfo.h"
#import "QGGlobalConst.h"
@interface
QGActivityPopControlModel
:
NSObject
/// 弹窗位置
@property
(
nonatomic
,
assign
)
NSInteger
position
;
/// 是否需要刷新
@property
(
nonatomic
,
assign
)
BOOL
shouldReset
;
@end
@implementation
QGActivityPopControlModel
@end
@interface
QGActivityPopManager
()
...
...
@@ -34,6 +47,14 @@
/// 等候显示的视图集合[QGActivityPopView] ,一旦用户切换了页面,那么这个页面的弹窗就会暂时进入等待显示集合,
@property
(
nonatomic
,
strong
)
NSMutableArray
*
waitPops
;
/// 显示弹窗的类的集合
@property
(
nonatomic
,
strong
)
NSMutableArray
*
popIndexs
;
///本次获取的已经显示和尚未显示的弹窗集合,便于清除
@property
(
nonatomic
,
strong
)
NSMutableArray
*
activePopViews
;
///本次获取的已经显示和尚未显示的浮窗集合,便于清除
@property
(
nonatomic
,
strong
)
NSMutableArray
*
floatsPopViews
;
/// 所有浮窗视图集合
@property
(
nonatomic
,
strong
)
NSMutableDictionary
*
floatsPops
;
/// 用户已经交互过浮窗id集合
...
...
@@ -80,36 +101,78 @@ static NSString * floats_pop_sets = @"floats_pop_sets";
/// 等待显示的弹窗集合
self
.
waitPops
=
[
NSMutableArray
array
];
self
.
floatsPops
=
[
NSMutableDictionary
dictionary
];
self
.
popIndexs
=
[
NSMutableArray
arrayWithCapacity
:
1
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
removeAllPopViews
)
name
:
ModelCenterUserLoginNotification
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
resetAllPopViews
)
name
:
ModelCenterUserLoginNotification
object
:
nil
];
}
return
self
;
}
/// 展示某个位置的活动弹窗
/// @param position 位置
/// @param controller 承载弹窗的父控制器
-
(
void
)
showActivitiesAtPosition
:(
QGActivityPosition
)
position
inController
:(
UIViewController
*
)
controller
/// 移除当前所有的弹窗
-
(
void
)
removeAllPopViews
{
if
(
position
==
0
)
return
;
if
(
controller
.
view
==
nil
)
return
;
@weakify
(
self
);
/// 网络获取该位置的活动弹窗
[
self
requestActivitiesWithIndex
:
position
complete
:
^
(
NSArray
*
activities
,
NSArray
*
floats
){
@strongify
(
self
);
/// 配置第一个弹窗
[
self
configsActivitiesWithIndex
:
position
controller
:
controller
];
/// 配置浮窗
[
self
configFloatWithIndex
:
position
controller
:
controller
];
/// 移除当前所有的弹窗视图
if
(
self
.
activePopViews
.
count
)
{
[
self
.
activePopViews
enumerateObjectsWithOptions
:
NSEnumerationReverse
usingBlock
:
^
(
UIView
*
_Nonnull
obj
,
NSUInteger
idx
,
BOOL
*
_Nonnull
stop
)
{
[
obj
removeFromSuperview
];
}];
[
self
.
activePopViews
removeAllObjects
];
}
/// 移除所有浮窗视图
if
(
self
.
floatsPopViews
.
count
)
{
[
self
.
floatsPopViews
enumerateObjectsWithOptions
:
NSEnumerationReverse
usingBlock
:
^
(
UIView
*
_Nonnull
obj
,
NSUInteger
idx
,
BOOL
*
_Nonnull
stop
)
{
[
obj
removeFromSuperview
];
}];
[
self
.
floatsPopViews
removeAllObjects
];
}
[
self
.
activePops
removeAllObjects
];
/// 清空本地的标记
[
self
cleanLocalUniques
];
for
(
QGActivityPopControlModel
*
model
in
self
.
popIndexs
)
{
model
.
shouldReset
=
YES
;
}
}
/// 重新设置所有的弹窗
-
(
void
)
resetAllPopViews
{
}
#pragma mark - 网络模块
/// 检查当前记录是否包含本次弹窗位置
/// 如果不包含记录本次弹窗的位置,以便于下次刷新
-
(
QGActivityPopControlModel
*
)
checkPopHadContainsWithIndex
:(
NSInteger
)
index
{
__block
QGActivityPopControlModel
*
model
=
nil
;
[
self
.
popIndexs
enumerateObjectsUsingBlock
:
^
(
QGActivityPopControlModel
*
_Nonnull
obj
,
NSUInteger
idx
,
BOOL
*
_Nonnull
stop
)
{
if
(
obj
.
position
==
index
)
{
model
=
obj
;
*
stop
=
YES
;
}
}];
if
(
!
model
)
{
model
=
[[
QGActivityPopControlModel
alloc
]
init
];
model
.
position
=
index
;
[
self
.
popIndexs
addObject
:
model
];
}
return
model
;
}
/// 内部方法,获取指定位置的活动弹窗
/// @param index 位置
-
(
void
)
requestActivitiesWithIndex
:(
NSInteger
)
index
complete
:(
void
(
^
)(
NSArray
*
activities
,
NSArray
*
floats
))
complete
{
/// 标记本次弹窗请求位置
QGActivityPopControlModel
*
model
=
[
self
checkPopHadContainsWithIndex
:
index
];
/// 请求数据开始
QGTalosNetwork
*
networking
=
[
QGTalosNetwork
shareManager
];
/// 参数传递
NSMutableDictionary
*
param
=
[
NSMutableDictionary
dictionary
];
...
...
@@ -131,6 +194,8 @@ static NSString * floats_pop_sets = @"floats_pop_sets";
if
(
complete
)
{
complete
(
activityModels
,
floatsModels
);
}
/// 弹窗不会再次刷新
model
.
shouldReset
=
NO
;
}
}
failure
:^
(
NSURLSessionDataTask
*
_Nonnull
task
,
NSError
*
_Nonnull
error
)
{
/// 如果失败,不提示,不做处理
...
...
@@ -142,7 +207,7 @@ static NSString * floats_pop_sets = @"floats_pop_sets";
/// 配置当前要显示的弹窗,默认是集合[0]的对象
/// @param index 弹窗的位置
/// @param controller 显示的父视图
-
(
void
)
configsActivitiesWithIndex
:(
NSInteger
)
index
controller
:(
UIViewController
*
)
controller
-
(
void
)
configsActivitie
View
sWithIndex
:(
NSInteger
)
index
controller
:(
UIViewController
*
)
controller
{
/// 第一次显示防止多线程同时访问,加锁
[
self
.
configLock
lock
];
...
...
@@ -154,25 +219,14 @@ static NSString * floats_pop_sets = @"floats_pop_sets";
@weakify
(
self
);
dispatch_async
(
dispatch_get_main_queue
(),
^
{
/// 获取最上面的弹窗
QGActivityPopModel
*
model
=
[
list
firstObject
];
for
(
QGActivityPopModel
*
model
in
list
)
{
/// 初始化弹窗系统
QGActivityPopView
*
pop
=
[[
QGActivityPopView
alloc
]
initWithPopModel
:
model
];
pop
.
position
=
index
;
pop
.
controller
=
controller
;
__weak
typeof
(
pop
)
weakPop
=
pop
;
/// 如果当前视图没有切换就直接显示,如果切换了就等待
if
(
!
[
self
canShowStatusWithController
:
controller
]
)
{
[
self
.
waitPops
addObject
:
weakPop
];
}
else
{
////浮窗显示
[
pop
showInView
:
controller
.
view
];
if
(
model
.
showType
==
3
)
{
[
self
saveUniqueIdWithModel
:
model
];
}
/// 统计
QGAppCoreModelClickEvent
*
event
=
[
QGAppCoreModelClickEvent
acmcEventWithPage
:[
self
pageNameWithIndex
:
index
]
path
:
nil
name
:
nil
detail_name
:
@"显示弹窗"
];
[
QGAnalyticsService
analyticsTrackWithEvent
:
event
];
}
[
self
.
activePopViews
addObject
:
pop
];
/// 加入待展示
[
self
.
waitPops
addObject
:
pop
];
/// 点击事件
pop
.
activityDismissBlock
=
^
(
NSInteger
position
,
QGActivityPopModel
*
popModel
,
UIViewController
*
aController
,
BOOL
isClose
)
{
@strongify
(
self
);
...
...
@@ -187,10 +241,14 @@ static NSString * floats_pop_sets = @"floats_pop_sets";
}
[
self
configNextActivityWithIndex
:
position
controller
:
aController
];
};
}
/// 立刻展示第一个
[
self
showActiesViewsWithIndex
:
index
inController
:
controller
];
});
/// 显示完成解锁
[
self
.
configLock
unlock
];
}
-
(
BOOL
)
canShowStatusWithController
:(
UIViewController
*
)
controller
...
...
@@ -209,6 +267,10 @@ static NSString * floats_pop_sets = @"floats_pop_sets";
}
-
(
void
)
cleanLocalUniques
{
[[
QGCacheManager
shareCacheManager
]
removeAppConfigWithKeys
:@[
floats_pop_sets
,
activities_pop_sets
]];
}
/// 显示立即标记,即showType = 3时
/// @param model 类型
...
...
@@ -260,7 +322,7 @@ static NSString * floats_pop_sets = @"floats_pop_sets";
[
self
.
activePops
setObject
:
muList
forKey
:[
NSString
stringWithFormat
:
@"%ld"
,(
long
)
index
]];
sleep
(
2
);
/// 重新配置新的活动窗口
[
self
configsActivitiesWithIndex
:
index
c
ontroller
:
controller
];
[
self
showActiesViewsWithIndex
:
index
inC
ontroller
:
controller
];
});
}
...
...
@@ -280,6 +342,7 @@ static NSString * floats_pop_sets = @"floats_pop_sets";
/// 初始化浮窗
QGActivityPopModel
*
model
=
[
list
firstObject
];
QGFloatsPopView
*
pop
=
[[
QGFloatsPopView
alloc
]
initWithModel
:
model
];
[
self
.
floatsPopViews
addObject
:
pop
];
/// block触发必定是只显示一次的
pop
.
dismissBlock
=
^
(
QGActivityPopModel
*
model
)
{
NSString
*
today
=
DateManager
().
defaultFormatterForTimestamp
([[
NSDate
date
]
timeIntervalSince1970
]);
...
...
@@ -314,7 +377,7 @@ static NSString * floats_pop_sets = @"floats_pop_sets";
return
nil
;
}
#pragma mark - 弹窗和浮窗数据
处理逻辑
#pragma mark - 弹窗和浮窗数据
过滤
/// 对弹窗源数据进行数据过滤,并限制最大为2条
-
(
NSArray
*
)
handleActivitiesWithIndex
:(
NSInteger
)
index
activities
:(
NSArray
*
)
popups
...
...
@@ -353,11 +416,11 @@ static NSString * floats_pop_sets = @"floats_pop_sets";
if
(
model
.
showType
==
1
)
{
// 点击后不再显示
if
(
!
[
self
.
invalidFloatPops
valueForKey
:[
NSString
stringWithFormat
:
@"%@"
,
model
.
uniqueId
]])
{
[
floatsModels
addObject
:
model
];
// 浮窗只能有一个
break
;
break
;
// 浮窗只能有一个
}
}
else
if
(
model
.
showType
==
2
){
[
floatsModels
addObject
:
model
];
break
;
// 浮窗只能有一个
}
}
...
...
@@ -365,31 +428,81 @@ static NSString * floats_pop_sets = @"floats_pop_sets";
return
floatsModels
;
}
/// 是否需要请求数据
-
(
BOOL
)
ifNeedRequestWithIndex
:(
NSInteger
)
index
{
/// 默认不存在就是需要请求
__block
BOOL
shouldReset
=
YES
;
[
self
.
popIndexs
enumerateObjectsUsingBlock
:
^
(
QGActivityPopControlModel
*
_Nonnull
model
,
NSUInteger
idx
,
BOOL
*
_Nonnull
stop
)
{
if
(
model
.
position
==
index
)
{
shouldReset
=
model
.
shouldReset
;
*
stop
=
YES
;
}
}];
return
shouldReset
;
}
#pragma mark - 查询并展示页面弹窗
/// 查询当前页面的视图展示
-
(
void
)
viewDidAppearAtPosition
:(
QGActivityPosition
)
position
inController
:(
UIViewController
*
)
controller
{
if
(
position
==
0
)
return
;
if
(
controller
.
view
==
nil
)
return
;
/// 加载
if
([
self
ifNeedRequestWithIndex
:
position
])
{
@weakify
(
self
);
/// 网络获取该位置的活动弹窗
[
self
requestActivitiesWithIndex
:
position
complete
:
^
(
NSArray
*
activities
,
NSArray
*
floats
){
@strongify
(
self
);
/// 配置弹窗
[
self
configsActivitieViewsWithIndex
:
position
controller
:
controller
];
/// 配置浮窗
[
self
configFloatWithIndex
:
position
controller
:
controller
];
}];
}
else
{
///展示
[
self
showActiesViewsWithIndex
:
position
inController
:
controller
];
}
}
/// 展示弹窗
-
(
void
)
showActiesViewsWithIndex
:(
QGActivityPosition
)
position
inController
:(
UIViewController
*
)
controller
{
/// 没有等待的窗口
if
(
self
.
waitPops
.
count
==
0
)
return
;
/// 上锁,以防多线程同时访问
[
self
.
lock
lock
];
[
self
.
waitPops
enumerateObjectsWithOptions
:
NSEnumerationReverse
usingBlock
:
^
(
QGActivityPopView
*
_Nonnull
pop
,
NSUInteger
idx
,
BOOL
*
_Nonnull
stop
)
{
dispatch_async
(
dispatch_get_global_queue
(
0
,
0
),
^
{
__block
QGActivityPopView
*
popView
=
nil
;
[
self
.
waitPops
enumerateObjectsWithOptions
:
NSEnumerationConcurrent
usingBlock
:
^
(
QGActivityPopView
*
_Nonnull
pop
,
NSUInteger
idx
,
BOOL
*
_Nonnull
stop
)
{
if
(
pop
.
controller
==
controller
&&
pop
.
position
==
position
)
{
popView
=
pop
;
*
stop
=
YES
;
}
}];
if
(
popView
)
{
[
self
showWaitPopWith
:
popView
];
}
});
}
/// 展示等待的视图
-
(
void
)
showWaitPopWith
:(
QGActivityPopView
*
)
pop
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
pop
.
controller
==
controller
&&
[
self
canShowStatusWithController
:
pop
.
controller
]
&&
pop
.
position
==
position
)
{
if
([
self
canShowStatusWithController
:
pop
.
controller
]
)
{
[
pop
showInView
:
pop
.
controller
.
view
];
/// 显示即标记
if
(
pop
.
popModel
.
showType
==
3
)
{
[
self
saveUniqueIdWithModel
:
pop
.
popModel
];
}
/// 一旦展示就清除
[
self
.
waitPops
removeObject
:
pop
];
QGAppCoreModelClickEvent
*
event
=
[
QGAppCoreModelClickEvent
acmcEventWithPage
:[
self
pageNameWithIndex
:
pop
.
position
]
path
:
nil
name
:
nil
detail_name
:
@"显示弹窗"
];
[
QGAnalyticsService
analyticsTrackWithEvent
:
event
];
*
stop
=
YES
;
}
});
}];
/// 解锁
[
self
.
lock
unlock
];
}
...
...
@@ -409,4 +522,10 @@ static NSString * floats_pop_sets = @"floats_pop_sets";
return
_configLock
;
}
-
(
void
)
dealloc
{
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
];
}
@end
VirtualPayment/VirtualPayment/QGClasses/Card/Function/QGActivityManager/QGActivityPopView.h
View file @
b703cda2
...
...
@@ -17,6 +17,9 @@ typedef void (^QGActivityShouldWaitBlock)(QGActivityPopView * _Nullable pop);
NS_ASSUME_NONNULL_BEGIN
@interface
QGActivityPopView
:
QGBasePopView
/// 是否正在显示
@property
(
nonatomic
,
assign
)
BOOL
showing
;
///位置
@property
(
nonatomic
,
assign
)
NSInteger
position
;
///在哪个类显示
...
...
VirtualPayment/VirtualPayment/QGClasses/Card/Function/QGActivityManager/QGActivityPopView.m
View file @
b703cda2
...
...
@@ -120,6 +120,7 @@
}
[
self
removeFromSuperview
];
}];
self
.
showing
=
NO
;
}
/// 点击内容关闭
...
...
@@ -159,7 +160,13 @@
}
}];
self
.
showing
=
NO
;
}
-
(
void
)
showInView
:(
UIView
*
)
superView
{
[
super
showInView
:
superView
];
self
.
showing
=
YES
;
}
/// 浮窗点击统计
...
...
VirtualPayment/VirtualPayment/QGClasses/Card/Function/QGCard/ViewController/QGCardViewController.m
View file @
b703cda2
...
...
@@ -72,16 +72,16 @@
[
self
uploadIPAddress
];
[
self
performSelector
:
@selector
(
showActivities
)
withObject
:
nil
afterDelay
:
2
.
0
];
//
[self performSelector:@selector(showActivities) withObject:nil afterDelay:2.0];
}
-
(
void
)
showActivities
{
QGActivityPopManager
*
manager
=
[
QGActivityPopManager
shareInstance
];
[
manager
showActivitiesAtPosition
:
QGActivityPositionHome
inController
:
self
];
}
//
- (void)showActivities
//
{
//
QGActivityPopManager *manager = [QGActivityPopManager shareInstance];
//
[manager showActivitiesAtPosition:QGActivityPositionHome inController:self];
//
//
}
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
{
...
...
VirtualPayment/VirtualPayment/QGClasses/Cashback/Function/QGProfit/ViewController/QGCashbackViewController.m
View file @
b703cda2
...
...
@@ -57,7 +57,7 @@
// Do any additional setup after loading the view.
[
self
initNormalUI
];
[
QGActivityPopManager
.
shareInstance
showActivitiesAtPosition
:
QGActivityPositionCashback
inController
:
self
];
//
[QGActivityPopManager.shareInstance showActivitiesAtPosition:QGActivityPositionCashback inController:self];
}
#pragma mark - 初始化数据
...
...
VirtualPayment/VirtualPayment/QGClasses/PreferentialMall/Function/QGMallHomePage/ViewController/QGMallContainerViewController.m
View file @
b703cda2
...
...
@@ -52,7 +52,7 @@
[
self
initNormalUI
];
[
self
requestMenuData
];
//弹窗
[
QGActivityPopManager
.
shareInstance
showActivitiesAtPosition
:
QGActivityPositionMall
inController
:
self
];
//
[QGActivityPopManager.shareInstance showActivitiesAtPosition:QGActivityPositionMall inController:self];
}
...
...
VirtualPayment/VirtualPayment/QGClasses/QuotaManager/Function/QuotaManager/ViewController/QGQuotaManagerViewController.m
View file @
b703cda2
...
...
@@ -46,7 +46,7 @@
[
self
custemLeftDefaultBarButtonItem
];
[
self
addRefresh
];
[
QGActivityPopManager
.
shareInstance
showActivitiesAtPosition
:
QGActivityPositionManager
inController
:
self
];
//
[QGActivityPopManager.shareInstance showActivitiesAtPosition:QGActivityPositionManager inController:self];
}
...
...
VirtualPayment/VirtualPayment/QGClasses/UserCenter/Function/QGNewUserCenter/ViewConntroller/QGNewUserCenterViewController.m
View file @
b703cda2
...
...
@@ -35,7 +35,7 @@
// Do any additional setup after loading the view.
[
self
initNormalUI
];
[
QGActivityPopManager
.
shareInstance
showActivitiesAtPosition
:
QGActivityPositionMine
inController
:
self
];
//
[QGActivityPopManager.shareInstance showActivitiesAtPosition:QGActivityPositionMine inController:self];
}
-
(
void
)
viewDidAppear
:(
BOOL
)
animated
...
...
VirtualPayment/VirtualPayment/QGUtils/QGTool/SystemManager.m
View file @
b703cda2
...
...
@@ -26,6 +26,15 @@
///上次推荐更新提示的日期
#define VCCLastUpdateHintDate @"VCCLastUpdateHintDate"
@interface
SystemManager
()
/// 内部应用粘贴板字符串
@property
(
nonatomic
,
copy
)
NSString
*
pasteboardString
;
/// 内部应用粘贴板字符串
@property
(
nonatomic
,
copy
)
NSArray
*
pasteboardStrings
;
@end
static
SystemManager
*
shareManager
=
nil
;
@implementation
SystemManager
...
...
@@ -50,8 +59,28 @@ static SystemManager * shareManager = nil;
-
(
id
)
init
{
self
=
[
super
init
];
if
(
self
)
{
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
pasteboardChanged
)
name
:
UIPasteboardChangedNotification
object
:
nil
];
}
return
self
;
}
-
(
void
)
pasteboardChanged
{
UIPasteboard
*
pasteboard
=
[
UIPasteboard
generalPasteboard
];
if
(
pasteboard
.
string
.
length
)
{
self
.
pasteboardString
=
pasteboard
.
string
;
self
.
pasteboardStrings
=
pasteboard
.
strings
;
}
else
{
self
.
pasteboardString
=
nil
;
self
.
pasteboardStrings
=
nil
;
}
}
#pragma mark -
/*************************/
...
...
@@ -177,7 +206,7 @@ static SystemManager * shareManager = nil;
{
NSString
*
pasteboardStr
=
[
UIPasteboard
generalPasteboard
].
string
;
//发现粘贴行为弹窗
if
(
!
[
NSString
isEmpty
:
pasteboardStr
]
&&
pasteboardStr
.
length
>
15
)
{
if
(
[
self
validatePasteboardString
]
)
{
QGPasteAlertView
*
alertView
=
[[
QGPasteAlertView
alloc
]
initWithPasteStr
:
pasteboardStr
];
[
alertView
showInView
:
nil
];
//清空粘贴板
...
...
@@ -192,6 +221,20 @@ static SystemManager * shareManager = nil;
}
}
/// 判断粘贴板的字符的有效性
-
(
BOOL
)
validatePasteboardString
{
NSString
*
string
=
[
UIPasteboard
generalPasteboard
].
string
;
/// 空或者字符串长度小于15
if
([
NSString
isEmpty
:
string
]
||
string
.
length
<=
15
)
return
NO
;
/// 与粘贴板相同
if
(
self
.
pasteboardString
&&
[
self
.
pasteboardString
isEqualToString
:
string
])
return
NO
;
/// 纯数字
if
([
string
isNumber
])
return
NO
;
return
YES
;
}
#pragma mark -
/*************************/
//自定义webviewUserAgent
...
...
@@ -281,4 +324,9 @@ static SystemManager * shareManager = nil;
}
-
(
void
)
dealloc
{
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
];
}
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment