Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
ios1x
Overview
Overview
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cemarose
ios1x
Commits
f961aa2c
Commit
f961aa2c
authored
Dec 11, 2017
by
houweibin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1,切换分类后,会重置前一个分类的筛选
2,切换tab以及返回前台后,将重新选中首个分类,并重置所有分类的筛选
parent
18b81387
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
1 deletions
+83
-1
KWMCategoryModel.h
iCemarose/Class/Model/KWMCategoryModel.h
+2
-0
KWMCategoryVC.m
iCemarose/Class/UI/Category/KWMCategoryVC.m
+73
-0
KWMMainVC.m
iCemarose/Class/UI/KWMMainVC.m
+8
-1
No files found.
iCemarose/Class/Model/KWMCategoryModel.h
View file @
f961aa2c
...
@@ -22,5 +22,7 @@
...
@@ -22,5 +22,7 @@
@property
(
nonatomic
)
NSMutableArray
<
KWMFilter
*>
*
filters
;
@property
(
nonatomic
)
NSMutableArray
<
KWMFilter
*>
*
filters
;
@property
(
nonatomic
)
NSString
*
brand
;
@property
(
nonatomic
)
NSString
*
brand
;
@property
(
nonatomic
)
CGFloat
offsetY
;
@property
(
nonatomic
)
CGFloat
offsetY
;
//切换分类后,如果原来有选中筛选规则的需要清除并重新刷新,以此字段标识
@property
(
nonatomic
)
BOOL
isNeedReload
;
@end
@end
iCemarose/Class/UI/Category/KWMCategoryVC.m
View file @
f961aa2c
...
@@ -64,6 +64,7 @@
...
@@ -64,6 +64,7 @@
-
(
void
)
viewDidLoad
{
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
[
super
viewDidLoad
];
[
self
registerResetPageNotification
];
[
self
initData
];
[
self
initData
];
[
self
initView
];
[
self
initView
];
[
self
requestAllBrandsApi
];
[
self
requestAllBrandsApi
];
...
@@ -85,6 +86,14 @@
...
@@ -85,6 +86,14 @@
[
self
.
navigationController
setNavigationBarHidden
:
NO
];
[
self
.
navigationController
setNavigationBarHidden
:
NO
];
}
}
-
(
void
)
dealloc
{
//如果大于等于ios9.0,不需要反注册了,从ios9.0开始通知中心会对观察者弱引用
NSString
*
version
=
[
UIDevice
currentDevice
].
systemVersion
;
if
(
version
.
doubleValue
<
9
.
0
)
{
[
self
unRegisterNotification
];
}
}
-
(
KWMCollectionRefreshUtil
*
)
refreshUtil
{
-
(
KWMCollectionRefreshUtil
*
)
refreshUtil
{
if
(
!
_refreshUtil
){
if
(
!
_refreshUtil
){
_refreshUtil
=
[
KWMCollectionRefreshUtil
new
];
_refreshUtil
=
[
KWMCollectionRefreshUtil
new
];
...
@@ -161,6 +170,66 @@
...
@@ -161,6 +170,66 @@
[
self
initCustomTitleBarConstarints
:
self
.
titleView
];
[
self
initCustomTitleBarConstarints
:
self
.
titleView
];
}
}
#pragma mark -- resetFilter resetPager
/* 每次切换tab和从首页重新回来的时候,都会清空筛选和选回首个分类
每次切换分类,都会清空掉该分类的筛选 */
//注册and反注册 重置筛选和选中分类的广播
-
(
void
)
registerResetPageNotification
{
//从后台返回前台时
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
resetPager
)
name
:
UIApplicationWillEnterForegroundNotification
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
resetPager
)
name
:
@"didSelectCategoryTab"
object
:
nil
];
}
-
(
void
)
unRegisterNotification
{
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
];
}
-
(
void
)
resetPager
{
[
self
resetAllOffset
];
[
self
resetAllFilter
];
[
self
resetCategorySelected
];
}
//移除筛选
//需要被重置的分类,标示isNeedReload,下次进入时,刷新
-
(
void
)
resetAllFilter
{
for
(
KWMCategoryModel
*
category
in
self
.
categories
)
{
BOOL
isNeedReload
=
NO
;
if
(
category
.
filters
&&
category
.
filters
.
count
>
0
){
[
category
.
filters
removeAllObjects
];
isNeedReload
=
YES
;
}
if
(
category
.
sort
!=
BUYCollectionSortCollectionDefault
){
category
.
sort
=
BUYCollectionSortCollectionDefault
;
isNeedReload
=
YES
;
}
if
(
category
.
brand
){
category
.
brand
=
nil
;
isNeedReload
=
YES
;
}
if
(
isNeedReload
){
category
.
isNeedReload
=
YES
;
category
.
offsetY
=
0
;
}
}
}
-
(
void
)
resetAllOffset
{
self
.
cvRightProduct
.
contentOffset
=
CGPointMake
(
0
,
0
);
for
(
KWMCategoryModel
*
category
in
self
.
categories
)
{
category
.
offsetY
=
0
;
}
}
-
(
void
)
resetCategorySelected
{
self
.
selectedCategory
=
self
.
categories
.
firstObject
;
NSIndexPath
*
path
=
[
NSIndexPath
indexPathForItem
:
0
inSection
:
0
];
if
([
self
.
tbvLeftCategory
numberOfRowsInSection
:
0
]
>
0
){
[
self
.
tbvLeftCategory
selectRowAtIndexPath
:
path
animated
:
YES
scrollPosition
:
UITableViewScrollPositionTop
];
}
}
#pragma mark -- KWMCategoryTitleDelegate
#pragma mark -- KWMCategoryTitleDelegate
-
(
void
)
kwm_onClickShopCart
{
-
(
void
)
kwm_onClickShopCart
{
KWMShopCartVC
*
shopCartVC
=
(
KWMShopCartVC
*
)[
KWMBaseVC
findControllerBy
:[
KWMShopCartVC
kwmTag
]
fromStoryboard
:
@"ShopCart"
];
KWMShopCartVC
*
shopCartVC
=
(
KWMShopCartVC
*
)[
KWMBaseVC
findControllerBy
:[
KWMShopCartVC
kwmTag
]
fromStoryboard
:
@"ShopCart"
];
...
@@ -191,6 +260,7 @@
...
@@ -191,6 +260,7 @@
// [self.cvRightProduct.mj_header endRefreshing];
// [self.cvRightProduct.mj_header endRefreshing];
// [self.cvRightProduct.mj_footer endRefreshing];
// [self.cvRightProduct.mj_footer endRefreshing];
self
.
selectedCategory
=
self
.
categories
[
indexPath
.
row
];
self
.
selectedCategory
=
self
.
categories
[
indexPath
.
row
];
[
self
resetAllFilter
];
}
}
#pragma mark - UICollectionViewDataSource
#pragma mark - UICollectionViewDataSource
...
@@ -316,6 +386,7 @@
...
@@ -316,6 +386,7 @@
self
.
filterTab
.
userInteractionEnabled
=
false
;
self
.
filterTab
.
userInteractionEnabled
=
false
;
KWMCategoryModel
*
cmodel
=
self
.
selectedCategory
;
KWMCategoryModel
*
cmodel
=
self
.
selectedCategory
;
cmodel
.
isNeedReload
=
NO
;
NSMutableArray
*
tags
=
[
KWMFilterUtil
getTagsByFilterArray
:
cmodel
.
filters
];
NSMutableArray
*
tags
=
[
KWMFilterUtil
getTagsByFilterArray
:
cmodel
.
filters
];
if
(
cmodel
.
brand
){
if
(
cmodel
.
brand
){
[
tags
addObject
:
cmodel
.
brand
];
[
tags
addObject
:
cmodel
.
brand
];
...
@@ -384,6 +455,8 @@
...
@@ -384,6 +455,8 @@
}
else
{
}
else
{
[
self
.
cvRightProduct
.
mj_header
beginRefreshing
];
[
self
.
cvRightProduct
.
mj_header
beginRefreshing
];
}
}
}
else
if
(
_selectedCategory
.
isNeedReload
){
[
self
.
refreshUtil
reLoadData
];
}
else
if
([
self
.
cvRightProduct
.
mj_header
isRefreshing
])
{
}
else
if
([
self
.
cvRightProduct
.
mj_header
isRefreshing
])
{
[
self
.
cvRightProduct
.
mj_header
endRefreshing
];
[
self
.
cvRightProduct
.
mj_header
endRefreshing
];
}
}
...
...
iCemarose/Class/UI/KWMMainVC.m
View file @
f961aa2c
...
@@ -181,6 +181,7 @@
...
@@ -181,6 +181,7 @@
tabBarItem2
.
image
=
image2
;
tabBarItem2
.
image
=
image2
;
image2
=
[[
UIImage
imageNamed
:
@"btn_tab_store_pre"
]
imageWithRenderingMode
:
UIImageRenderingModeAlwaysOriginal
];
image2
=
[[
UIImage
imageNamed
:
@"btn_tab_store_pre"
]
imageWithRenderingMode
:
UIImageRenderingModeAlwaysOriginal
];
tabBarItem2
.
selectedImage
=
image2
;
tabBarItem2
.
selectedImage
=
image2
;
tabBarItem2
.
tag
=
101
;
UIImage
*
image3
=
[[
UIImage
imageNamed
:
@"btn_tab_ brand"
]
imageWithRenderingMode
:
UIImageRenderingModeAlwaysOriginal
];
UIImage
*
image3
=
[[
UIImage
imageNamed
:
@"btn_tab_ brand"
]
imageWithRenderingMode
:
UIImageRenderingModeAlwaysOriginal
];
...
@@ -216,6 +217,12 @@
...
@@ -216,6 +217,12 @@
}
}
-
(
void
)
tabBar
:
(
UITabBar
*
)
tabBar
didSelectItem
:
(
UITabBarItem
*
)
item
{
// 这里不需要调用super,因为父类没有实现这个代理方法
//[super tabBar:tabBar didSelectItem:item];
if
(
item
.
tag
==
101
){
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
@"didSelectCategoryTab"
object
:
nil
];
}
}
@end
@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