Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
GMBase
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
GMBase
Commits
6ba7991a
Commit
6ba7991a
authored
Mar 30, 2021
by
艾娇平
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ajp/dev' into 'master'
让JXPageView支持多组数据展示 See merge request
!34
parents
2e30e00c
aa147bcc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
37 deletions
+55
-37
JXPagerView.h
GMBase/Classes/JXPagerView/JXPagerView.h
+18
-13
JXPagerView.m
GMBase/Classes/JXPagerView/JXPagerView.m
+37
-24
No files found.
GMBase/Classes/JXPagerView/JXPagerView.h
View file @
6ba7991a
...
@@ -32,7 +32,6 @@
...
@@ -32,7 +32,6 @@
*/
*/
-
(
UIScrollView
*
)
listScrollView
;
-
(
UIScrollView
*
)
listScrollView
;
/**
/**
当listView内部持有的UIScrollView或UITableView或UICollectionView的代理方法`scrollViewDidScroll`回调时,需要调用该代理方法传入的callback
当listView内部持有的UIScrollView或UITableView或UICollectionView的代理方法`scrollViewDidScroll`回调时,需要调用该代理方法传入的callback
...
@@ -51,6 +50,11 @@
...
@@ -51,6 +50,11 @@
@protocol
JXPagerViewDelegate
<
NSObject
>
@protocol
JXPagerViewDelegate
<
NSObject
>
-
(
id
<
JXPagerViewListViewDelegate
>
)
pagerView
:
(
JXPagerView
*
)
pagerView
initListAtIndex
:
(
NSInteger
)
index
;
-
(
void
)
pagerView
:(
JXPagerView
*
)
pagerView
didScroll
:(
NSInteger
)
row
;
@optional
/**
/**
返回tableHeaderView的高度,因为内部需要比对判断,只能是整型数
返回tableHeaderView的高度,因为内部需要比对判断,只能是整型数
...
@@ -59,7 +63,6 @@
...
@@ -59,7 +63,6 @@
*/
*/
-
(
NSUInteger
)
tableHeaderViewHeightInPagerView
:
(
JXPagerView
*
)
pagerView
;
-
(
NSUInteger
)
tableHeaderViewHeightInPagerView
:
(
JXPagerView
*
)
pagerView
;
/**
/**
返回tableHeaderView
返回tableHeaderView
...
@@ -68,7 +71,6 @@
...
@@ -68,7 +71,6 @@
*/
*/
-
(
UIView
*
)
tableHeaderViewInPagerView
:(
JXPagerView
*
)
pagerView
;
-
(
UIView
*
)
tableHeaderViewInPagerView
:(
JXPagerView
*
)
pagerView
;
/**
/**
返回悬浮HeaderView的高度,因为内部需要比对判断,只能是整型数
返回悬浮HeaderView的高度,因为内部需要比对判断,只能是整型数
...
@@ -77,7 +79,6 @@
...
@@ -77,7 +79,6 @@
*/
*/
-
(
NSUInteger
)
heightForPinSectionHeaderInPagerView
:(
JXPagerView
*
)
pagerView
;
-
(
NSUInteger
)
heightForPinSectionHeaderInPagerView
:(
JXPagerView
*
)
pagerView
;
/**
/**
返回悬浮HeaderView。我用的是自己封装的JXCategoryView(Github:https://github.com/pujiaxin33/JXCategoryView),你也可以选择其他的三方库或者自己写
返回悬浮HeaderView。我用的是自己封装的JXCategoryView(Github:https://github.com/pujiaxin33/JXCategoryView),你也可以选择其他的三方库或者自己写
...
@@ -102,14 +103,8 @@
...
@@ -102,14 +103,8 @@
@param index index description
@param index index description
@return 新生成的列表实例
@return 新生成的列表实例
*/
*/
-
(
id
<
JXPagerViewListViewDelegate
>
)
pagerView
:(
JXPagerView
*
)
pagerView
initListAtIndex
:(
NSInteger
)
index
;
-
(
void
)
pagerView
:(
JXPagerView
*
)
pagerView
didScroll
:(
NSInteger
)
row
;
@optional
/**
/**
返回tableHeaderView 距离pagerView顶部的距离 默认为 0
返回tableHeaderView 距离pagerView顶部的距离 默认为 0
*/
*/
-
(
CGFloat
)
tableViewSectionHeaderViewContentYInPagerView
:(
JXPagerView
*
)
pagerView
;
-
(
CGFloat
)
tableViewSectionHeaderViewContentYInPagerView
:(
JXPagerView
*
)
pagerView
;
/**
/**
...
@@ -123,7 +118,7 @@
...
@@ -123,7 +118,7 @@
-
(
void
)
mainTableViewWillBeginDragging
:(
UIScrollView
*
)
scrollView
;
-
(
void
)
mainTableViewWillBeginDragging
:(
UIScrollView
*
)
scrollView
;
/**
/**
@param
由于 mainTableViewDidScroll 滚动偏移量返回的最大值为headerView的高度, 这个偏移量加上子ScrollView的偏移量。
由于 mainTableViewDidScroll 滚动偏移量返回的最大值为headerView的高度, 这个偏移量加上子ScrollView的偏移量。
*/
*/
-
(
void
)
listAndMainScrollViewDidScroll
:(
CGFloat
)
contentOffsetY
;
-
(
void
)
listAndMainScrollViewDidScroll
:(
CGFloat
)
contentOffsetY
;
...
@@ -135,7 +130,7 @@
...
@@ -135,7 +130,7 @@
@property
(
nonatomic
,
strong
)
JXPagerMainTableView
*
mainTableView
;
@property
(
nonatomic
,
strong
)
JXPagerMainTableView
*
mainTableView
;
@property
(
nonatomic
,
strong
,
readonly
)
JXPagerListContainerView
*
listContainerView
;
@property
(
nonatomic
,
strong
)
JXPagerListContainerView
*
listContainerView
;
-
(
instancetype
)
initWithDelegate
:(
id
<
JXPagerViewDelegate
>
)
delegate
NS_DESIGNATED_INITIALIZER
;
-
(
instancetype
)
initWithDelegate
:(
id
<
JXPagerViewDelegate
>
)
delegate
NS_DESIGNATED_INITIALIZER
;
...
@@ -166,9 +161,19 @@
...
@@ -166,9 +161,19 @@
@property
(
nonatomic
,
strong
,
readonly
)
NSDictionary
<
NSNumber
*
,
id
<
JXPagerViewListViewDelegate
>>
*
validListDict
;
//暴露给子类使用,请勿直接使用该属性!当前已经加载过可用的列表字典,key就是index值,value是对应的列表。
@property
(
nonatomic
,
strong
,
readonly
)
NSDictionary
<
NSNumber
*
,
id
<
JXPagerViewListViewDelegate
>>
*
validListDict
;
//暴露给子类使用,请勿直接使用该属性!当前已经加载过可用的列表字典,key就是index值,value是对应的列表。
-
(
void
)
preferredProcessListViewDidScroll
:(
UIScrollView
*
)
scrollView
;
-
(
void
)
preferredProcessListViewDidScroll
:(
UIScrollView
*
)
scrollView
;
-
(
void
)
preferredProcessMainTableViewDidScroll
:(
UIScrollView
*
)
scrollView
;
-
(
void
)
preferredProcessMainTableViewDidScroll
:(
UIScrollView
*
)
scrollView
;
// 获取listContainer的Cell
-
(
UITableViewCell
*
)
listContainerCellForRowAtIndexPath
:(
NSIndexPath
*
)
indexPath
;
-
(
CGFloat
)
listContainerCellHeight
;
#pragma mark - UIScrollViewDelegate
/// 直接调用JXPagerView 内部的滑动代理实现
-
(
void
)
scrollViewDidScroll
:(
UIScrollView
*
)
scrollView
;
-
(
void
)
scrollViewDidEndDecelerating
:(
UIScrollView
*
)
scrollView
;
-
(
void
)
scrollViewDidEndDragging
:(
UIScrollView
*
)
scrollView
willDecelerate
:(
BOOL
)
decelerate
;
-
(
void
)
scrollViewWillBeginDragging
:(
UIScrollView
*
)
scrollView
;
-
(
void
)
scrollViewDidEndScrollingAnimation
:(
UIScrollView
*
)
scrollView
;
@end
@end
GMBase/Classes/JXPagerView/JXPagerView.m
View file @
6ba7991a
...
@@ -7,13 +7,15 @@
...
@@ -7,13 +7,15 @@
//
//
#import "JXPagerView.h"
#import "JXPagerView.h"
static
NSString
*
const
kGM_ListCellIdentifier
=
@"gm_ListCellIdentifier"
;
@import
GMRefresh
;
@import
GMRefresh
;
@interface
JXPagerView
()
<
UITableViewDataSource
,
UITableViewDelegate
,
JXPagerListContainerViewDelegate
>
@interface
JXPagerView
()
<
UITableViewDataSource
,
UITableViewDelegate
,
JXPagerListContainerViewDelegate
>
//@property (nonatomic, strong) JXPagerMainTableView *mainTableView;
@property
(
nonatomic
,
strong
)
JXPagerListContainerView
*
listContainerView
;
@property
(
nonatomic
,
strong
)
UIScrollView
*
currentScrollingListView
;
@property
(
nonatomic
,
strong
)
UIScrollView
*
currentScrollingListView
;
@property
(
nonatomic
,
weak
)
id
<
JXPagerViewListViewDelegate
>
currentList
;
@property
(
nonatomic
,
weak
)
id
<
JXPagerViewListViewDelegate
>
currentList
;
@property
(
nonatomic
,
strong
)
UITableViewCell
*
listContainerCell
;
@property
(
nonatomic
,
strong
)
NSMutableDictionary
<
NSNumber
*
,
id
<
JXPagerViewListViewDelegate
>>
*
validListDict
;
@property
(
nonatomic
,
strong
)
NSMutableDictionary
<
NSNumber
*
,
id
<
JXPagerViewListViewDelegate
>>
*
validListDict
;
@property
(
nonatomic
,
assign
)
CGFloat
mainViewScrollOffsetY
;
@property
(
nonatomic
,
assign
)
CGFloat
mainViewScrollOffsetY
;
@property
(
nonatomic
,
assign
)
BOOL
isListScroll
;
@property
(
nonatomic
,
assign
)
BOOL
isListScroll
;
...
@@ -41,7 +43,7 @@
...
@@ -41,7 +43,7 @@
self
.
mainTableView
.
dataSource
=
self
;
self
.
mainTableView
.
dataSource
=
self
;
self
.
mainTableView
.
delegate
=
self
;
self
.
mainTableView
.
delegate
=
self
;
[
self
refreshTableHeaderView
];
[
self
refreshTableHeaderView
];
[
self
.
mainTableView
registerClass
:[
UITableViewCell
class
]
forCellReuseIdentifier
:
@"cell"
];
[
self
.
mainTableView
registerClass
:[
UITableViewCell
class
]
forCellReuseIdentifier
:
kGM_ListCellIdentifier
];
if
(
@available
(
iOS
11
.
0
,
*
))
{
if
(
@available
(
iOS
11
.
0
,
*
))
{
self
.
mainTableView
.
contentInsetAdjustmentBehavior
=
UIScrollViewContentInsetAdjustmentNever
;
self
.
mainTableView
.
contentInsetAdjustmentBehavior
=
UIScrollViewContentInsetAdjustmentNever
;
}
}
...
@@ -67,25 +69,24 @@
...
@@ -67,25 +69,24 @@
-
(
void
)
reloadData
{
-
(
void
)
reloadData
{
self
.
currentList
=
nil
;
self
.
currentList
=
nil
;
self
.
currentScrollingListView
=
nil
;
self
.
currentScrollingListView
=
nil
;
self
.
listContainerCell
=
nil
;
for
(
id
<
JXPagerViewListViewDelegate
>
list
in
self
.
validListDict
.
allValues
)
{
for
(
id
<
JXPagerViewListViewDelegate
>
list
in
self
.
validListDict
.
allValues
)
{
[
list
.
listView
removeFromSuperview
];
[
list
.
listView
removeFromSuperview
];
}
}
[
_validListDict
removeAllObjects
];
[
_validListDict
removeAllObjects
];
[
self
refreshTableHeaderView
];
[
self
refreshTableHeaderView
];
[
self
.
mainTableView
reloadData
];
[
self
.
mainTableView
reloadData
];
[
self
.
listContainerView
reloadData
];
[
self
.
listContainerView
reloadData
];
}
}
-
(
void
)
refreshTableHeaderView
{
-
(
void
)
refreshTableHeaderView
{
if
([
self
.
delegate
respondsToSelector
:
@selector
(
tableHeaderViewInPagerView
:)])
{
UIView
*
tableHeaderView
=
[
self
.
delegate
tableHeaderViewInPagerView
:
self
];
UIView
*
tableHeaderView
=
[
self
.
delegate
tableHeaderViewInPagerView
:
self
];
// UIView *containerView = [[UIView alloc] initWithFrame:tableHeaderView.bounds];
// [containerView addSubview:tableHeaderView];
self
.
mainTableView
.
tableHeaderView
=
tableHeaderView
;
self
.
mainTableView
.
tableHeaderView
=
tableHeaderView
;
}
}
}
-
(
void
)
preferredProcessListViewDidScroll
:
(
UIScrollView
*
)
scrollView
{
-
(
void
)
preferredProcessListViewDidScroll
:
(
UIScrollView
*
)
scrollView
{
CGFloat
listScrollOffsetY
=
scrollView
.
contentOffset
.
y
;
CGFloat
listScrollOffsetY
=
scrollView
.
contentOffset
.
y
;
if
([
self
.
delegate
respondsToSelector
:
@selector
(
listAndMainScrollViewDidScroll
:)])
{
if
([
self
.
delegate
respondsToSelector
:
@selector
(
listAndMainScrollViewDidScroll
:)])
{
...
@@ -135,10 +136,31 @@
...
@@ -135,10 +136,31 @@
[
self
preferredProcessListViewDidScroll
:
scrollView
];
[
self
preferredProcessListViewDidScroll
:
scrollView
];
}
}
-
(
UITableViewCell
*
)
listContainerCellForRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
UITableViewCell
*
cell
=
self
.
listContainerCell
;
if
(
!
cell
)
{
cell
=
[
self
.
mainTableView
dequeueReusableCellWithIdentifier
:
kGM_ListCellIdentifier
forIndexPath
:
indexPath
];
cell
.
selectionStyle
=
UITableViewCellSelectionStyleNone
;
self
.
listContainerCell
=
cell
;
for
(
UIView
*
view
in
cell
.
contentView
.
subviews
)
{
[
view
removeFromSuperview
];
}
self
.
listContainerView
.
frame
=
CGRectMake
(
0
,
0
,
cell
.
contentView
.
bounds
.
size
.
width
,
cell
.
contentView
.
bounds
.
size
.
height
);
[
cell
.
contentView
addSubview
:
self
.
listContainerView
];
}
return
cell
;
}
-
(
CGFloat
)
listContainerCellHeight
{
return
self
.
bounds
.
size
.
height
;
}
#pragma mark - UITableViewDataSource, UITableViewDelegate
#pragma mark - UITableViewDataSource, UITableViewDelegate
-
(
NSInteger
)
numberOfSectionsInTableView
:
(
UITableView
*
)
tableView
{
-
(
NSInteger
)
numberOfSectionsInTableView
:
(
UITableView
*
)
tableView
{
return
1
;
return
1
;
}
}
-
(
NSInteger
)
tableView
:
(
UITableView
*
)
tableView
numberOfRowsInSection
:
(
NSInteger
)
section
{
-
(
NSInteger
)
tableView
:
(
UITableView
*
)
tableView
numberOfRowsInSection
:
(
NSInteger
)
section
{
return
1
;
return
1
;
}
}
...
@@ -149,13 +171,8 @@
...
@@ -149,13 +171,8 @@
}
}
-
(
UITableViewCell
*
)
tableView
:
(
UITableView
*
)
tableView
cellForRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
-
(
UITableViewCell
*
)
tableView
:
(
UITableView
*
)
tableView
cellForRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
UITableViewCell
*
cell
=
[
tableView
dequeueReusableCellWithIdentifier
:
@"cell"
forIndexPath
:
indexPath
];
for
(
UIView
*
view
in
cell
.
contentView
.
subviews
)
{
return
[
self
listContainerCellForRowAtIndexPath
:
indexPath
];
[
view
removeFromSuperview
];
}
self
.
listContainerView
.
frame
=
cell
.
contentView
.
bounds
;
[
cell
.
contentView
addSubview
:
self
.
listContainerView
];
return
cell
;
}
}
-
(
CGFloat
)
tableView
:
(
UITableView
*
)
tableView
heightForHeaderInSection
:
(
NSInteger
)
section
{
-
(
CGFloat
)
tableView
:
(
UITableView
*
)
tableView
heightForHeaderInSection
:
(
NSInteger
)
section
{
...
@@ -175,41 +192,37 @@
...
@@ -175,41 +192,37 @@
footer
.
backgroundColor
=
[
UIColor
clearColor
];
footer
.
backgroundColor
=
[
UIColor
clearColor
];
return
footer
;
return
footer
;
}
}
#pragma mark - UIScrollViewDelegate
-
(
void
)
scrollViewDidScroll
:
(
UIScrollView
*
)
scrollView
{
-
(
void
)
scrollViewDidScroll
:
(
UIScrollView
*
)
scrollView
{
if
(
self
.
mainTableView
.
mj_header
.
refreshing
)
{
if
(
self
.
mainTableView
.
mj_header
.
refreshing
)
{
return
;
return
;
}
}
CGFloat
sectionHeaderHeight
=
[
self
.
delegate
heightForPinSectionHeaderInPagerView
:
self
];
CGFloat
sectionHeaderHeight
=
0
;
if
([
self
.
delegate
respondsToSelector
:
@selector
(
heightForPinSectionHeaderInPagerView
:)])
{
sectionHeaderHeight
=
[
self
.
delegate
heightForPinSectionHeaderInPagerView
:
self
];
}
CGFloat
sectionHeaderContentY
=
0
;
CGFloat
sectionHeaderContentY
=
0
;
if
([
self
.
delegate
respondsToSelector
:
@selector
(
tableViewSectionHeaderViewContentYInPagerView
:)])
{
if
([
self
.
delegate
respondsToSelector
:
@selector
(
tableViewSectionHeaderViewContentYInPagerView
:)])
{
sectionHeaderContentY
=
[
self
.
delegate
tableViewSectionHeaderViewContentYInPagerView
:
self
];
sectionHeaderContentY
=
[
self
.
delegate
tableViewSectionHeaderViewContentYInPagerView
:
self
];
}
}
CGFloat
ceilPositon
=
[
self
.
delegate
tableHeaderViewHeightInPagerView
:
self
]
-
sectionHeaderHeight
-
sectionHeaderContentY
;
CGFloat
ceilPositon
=
[
self
.
delegate
tableHeaderViewHeightInPagerView
:
self
]
-
sectionHeaderHeight
-
sectionHeaderContentY
;
if
(
scrollView
.
contentOffset
.
y
<
sectionHeaderHeight
)
{
if
(
scrollView
.
contentOffset
.
y
<
sectionHeaderHeight
)
{
scrollView
.
contentInset
=
UIEdgeInsetsMake
(
0
,
0
,
0
,
0
);
scrollView
.
contentInset
=
UIEdgeInsetsMake
(
0
,
0
,
0
,
0
);
}
}
if
(
scrollView
.
contentOffset
.
y
>=
ceilPositon
&&
scrollView
.
contentOffset
.
y
>=
sectionHeaderHeight
)
{
if
(
scrollView
.
contentOffset
.
y
>=
ceilPositon
&&
scrollView
.
contentOffset
.
y
>=
sectionHeaderHeight
)
{
scrollView
.
contentInset
=
UIEdgeInsetsMake
(
sectionHeaderContentY
,
0
,
0
,
0
);
scrollView
.
contentInset
=
UIEdgeInsetsMake
(
sectionHeaderContentY
,
0
,
0
,
0
);
}
}
CGFloat
offsetY
=
scrollView
.
contentOffset
.
y
;
CGFloat
offsetY
=
scrollView
.
contentOffset
.
y
;
self
.
mainViewScrollOffsetY
=
offsetY
;
self
.
mainViewScrollOffsetY
=
offsetY
;
if
([
self
.
delegate
respondsToSelector
:
@selector
(
mainTableViewDidScroll
:)])
{
if
([
self
.
delegate
respondsToSelector
:
@selector
(
mainTableViewDidScroll
:)])
{
[
self
.
delegate
mainTableViewDidScroll
:
scrollView
];
[
self
.
delegate
mainTableViewDidScroll
:
scrollView
];
}
}
if
(
scrollView
.
isTracking
&&
self
.
isListHorizontalScrollEnabled
)
{
if
(
scrollView
.
isTracking
&&
self
.
isListHorizontalScrollEnabled
)
{
self
.
listContainerView
.
collectionView
.
scrollEnabled
=
NO
;
self
.
listContainerView
.
collectionView
.
scrollEnabled
=
NO
;
}
}
[
self
preferredProcessMainTableViewDidScroll
:
scrollView
];
[
self
preferredProcessMainTableViewDidScroll
:
scrollView
];
}
}
...
...
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