fix:修正首页列表显示问题

This commit is contained in:
eggmanQQQ
2024-11-15 10:57:12 +08:00
parent 4cf14841cf
commit bede4a80c7

View File

@@ -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];
}