fix:修正首页列表显示问题
This commit is contained in:
@@ -98,7 +98,7 @@
|
||||
@interface XPHomePartyViewController ()<UICollectionViewDelegate, UICollectionViewDataSource, XPHomeProtocol>
|
||||
///数据源
|
||||
@property (nonatomic,strong) NSMutableArray *datasource;
|
||||
@property (nonatomic,strong) NSMutableArray *displayDatasource;
|
||||
|
||||
///列表
|
||||
@property (nonatomic,strong) UICollectionView *collectionView;
|
||||
///当前的页数
|
||||
@@ -172,13 +172,13 @@
|
||||
|
||||
#pragma mark - UICollectionViewDelegate And UICollectionViewDataSource
|
||||
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
if(self.displayDatasource.count == 0){
|
||||
if(self.datasource.count == 0){
|
||||
XPGuildEmptyCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGuildEmptyCollectionViewCell class]) forIndexPath:indexPath];
|
||||
[cell setConstraints];
|
||||
[cell setTitle:YMLocalizedString(@"XPGuildEmptyCollectionViewCell0")];
|
||||
return cell;
|
||||
}
|
||||
id item = [self.displayDatasource xpSafeObjectAtIndex:indexPath.row];
|
||||
id item = [self.datasource xpSafeObjectAtIndex:indexPath.row];
|
||||
if ([item isKindOfClass:[NSArray class]]) {
|
||||
HomePartyBannerCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([HomePartyBannerCell class])
|
||||
forIndexPath:indexPath];
|
||||
@@ -193,24 +193,24 @@
|
||||
return cell;
|
||||
} else {
|
||||
XPNewHomePartyCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPNewHomePartyCollectionViewCell class]) forIndexPath:indexPath];
|
||||
cell.roomInfo = [self.displayDatasource xpSafeObjectAtIndex:indexPath.row];
|
||||
cell.roomInfo = [self.datasource xpSafeObjectAtIndex:indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger)collectionView:(nonnull UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
||||
if(self.displayDatasource.count == 0) {
|
||||
if(self.datasource.count == 0) {
|
||||
return 1;
|
||||
}
|
||||
return self.displayDatasource.count;
|
||||
return self.datasource.count;
|
||||
}
|
||||
|
||||
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
if(self.displayDatasource.count == 0) {
|
||||
if(self.datasource.count == 0) {
|
||||
return self.collectionView.frame.size;
|
||||
}
|
||||
|
||||
id item = [self.displayDatasource xpSafeObjectAtIndex:indexPath.row];
|
||||
id item = [self.datasource xpSafeObjectAtIndex:indexPath.row];
|
||||
if ([item isKindOfClass:[NSArray class]]) {
|
||||
return CGSizeMake(kGetScaleWidth(345), kGetScaleWidth(118));
|
||||
} else {
|
||||
@@ -219,7 +219,7 @@
|
||||
}
|
||||
|
||||
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
id item = [self.displayDatasource xpSafeObjectAtIndex:indexPath.row];
|
||||
id item = [self.datasource xpSafeObjectAtIndex:indexPath.row];
|
||||
if ([item isKindOfClass:[NSArray class]]) {
|
||||
|
||||
} else {
|
||||
@@ -258,7 +258,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
self.displayDatasource = mutableArrayA.mutableCopy;
|
||||
self.datasource = mutableArrayA.mutableCopy;
|
||||
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
@@ -271,11 +271,10 @@
|
||||
|
||||
if(self.page == 1){
|
||||
self.datasource = [NSMutableArray arrayWithArray:list];
|
||||
[self sortDataSource];
|
||||
}else{
|
||||
[self.datasource addObjectsFromArray:list];
|
||||
}
|
||||
|
||||
[self sortDataSource];
|
||||
[[NSNotificationCenter defaultCenter]postNotificationName:@"khomeVCRefreshComplete" object:nil];
|
||||
}
|
||||
|
||||
@@ -285,6 +284,7 @@
|
||||
}
|
||||
|
||||
- (void)getHomeRecommendRoomListFail:(NSString *)message{
|
||||
self.page--;
|
||||
[self.collectionView.mj_footer endRefreshing];
|
||||
[[NSNotificationCenter defaultCenter]postNotificationName:@"khomeVCRefreshComplete" object:nil];
|
||||
}
|
||||
|
Reference in New Issue
Block a user