Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
GMPhobos
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
GMPhobos
Commits
91445fa1
Commit
91445fa1
authored
Sep 08, 2017
by
汪洋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
被present的controller也可以自动获取referer与referrerId。referer改为可以set
parent
0ac7c414
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
16 deletions
+32
-16
UIResponder+PhobosPV.m
Pod/Classes/UIResponder+PhobosPV.m
+32
-16
No files found.
Pod/Classes/UIResponder+PhobosPV.m
View file @
91445fa1
...
...
@@ -17,24 +17,33 @@
*
* @brief 取当前导航栈中当前VC的上级VC,如果该VC存在,就获取他的pageName
*
* @return 前一页的pageName
*
* @since 5.9.1
*/
-
(
void
)
initReferer
{
if
([
self
isKindOfClass
:[
UIViewController
class
]])
{
NSArray
*
navigationPool
=
((
UIViewController
*
)
self
).
navigationController
.
viewControllers
;
NSInteger
refererIndex
=
navigationPool
.
count
-
2
;
if
(
refererIndex
<
0
)
{
return
;
// 只有不为空,且是controller的情况下才自动获取
if
(
self
.
referer
==
nil
&&
[
self
isKindOfClass
:[
UIViewController
class
]])
{
// 分present与navigation两种情况
UIViewController
*
me
=
(
UIViewController
*
)
self
;
if
(
me
.
presentingViewController
!=
nil
)
{
objc_setAssociatedObject
(
self
,
@selector
(
referer
),
me
.
presentingViewController
.
pageName
,
OBJC_ASSOCIATION_COPY
);
}
else
{
NSArray
*
navigationPool
=
((
UIViewController
*
)
self
).
navigationController
.
viewControllers
;
NSInteger
refererIndex
=
navigationPool
.
count
-
2
;
if
(
refererIndex
<
0
)
{
return
;
}
UIViewController
*
controller
=
navigationPool
[
refererIndex
];
objc_setAssociatedObject
(
self
,
@selector
(
referer
),
controller
.
pageName
,
OBJC_ASSOCIATION_COPY
);
}
UIViewController
*
controller
=
navigationPool
[
refererIndex
];
objc_setAssociatedObject
(
self
,
@selector
(
referer
),
controller
.
pageName
,
OBJC_ASSOCIATION_COPY
);
}
else
{
objc_setAssociatedObject
(
self
,
@selector
(
referer
),
@""
,
OBJC_ASSOCIATION_COPY
);
}
}
-
(
void
)
setReferer
:
(
NSString
*
)
referer
{
objc_setAssociatedObject
(
self
,
@selector
(
referer
),
referer
,
OBJC_ASSOCIATION_COPY
);
}
-
(
NSString
*
)
referer
{
NSString
*
referer
=
objc_getAssociatedObject
(
self
,
@selector
(
referer
));
...
...
@@ -73,15 +82,22 @@
}
-
(
void
)
initReferrerIdIfNil
{
// 只有不为空,且是controller的情况下才自动获取
if
(
self
.
referrerId
==
nil
&&
[
self
isKindOfClass
:[
UIViewController
class
]])
{
NSArray
*
navigationPool
=
((
UIViewController
*
)
self
).
navigationController
.
viewControllers
;
NSInteger
refererIdIndex
=
navigationPool
.
count
-
2
;
if
(
refererIdIndex
<
0
)
{
objc_setAssociatedObject
(
self
,
@selector
(
referrerId
),
@""
,
OBJC_ASSOCIATION_COPY
);
// 分present与navigation两种情况
UIViewController
*
me
=
(
UIViewController
*
)
self
;
if
(
me
.
presentingViewController
!=
nil
)
{
objc_setAssociatedObject
(
self
,
@selector
(
referrerId
),
me
.
presentingViewController
.
businessId
,
OBJC_ASSOCIATION_COPY
);
}
else
{
UIViewController
*
controller
=
navigationPool
[
refererIdIndex
];
NSString
*
preBusinessId
=
controller
.
businessId
;
objc_setAssociatedObject
(
self
,
@selector
(
referrerId
),
preBusinessId
,
OBJC_ASSOCIATION_COPY
);
NSArray
*
navigationPool
=
((
UIViewController
*
)
self
).
navigationController
.
viewControllers
;
NSInteger
refererIdIndex
=
navigationPool
.
count
-
2
;
if
(
refererIdIndex
<
0
)
{
objc_setAssociatedObject
(
self
,
@selector
(
referrerId
),
@""
,
OBJC_ASSOCIATION_COPY
);
}
else
{
UIViewController
*
controller
=
navigationPool
[
refererIdIndex
];
NSString
*
preBusinessId
=
controller
.
businessId
;
objc_setAssociatedObject
(
self
,
@selector
(
referrerId
),
preBusinessId
,
OBJC_ASSOCIATION_COPY
);
}
}
}
}
...
...
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