个播滚动优化

This commit is contained in:
fengshuo
2022-08-11 11:33:38 +08:00
parent 1fa07e3f27
commit c37b6b9a64
8 changed files with 46 additions and 28 deletions

View File

@@ -221,4 +221,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 034aba5260596f012774aa92cf2207105b5af99f
COCOAPODS: 1.11.2
COCOAPODS: 1.11.3

View File

@@ -217,12 +217,13 @@
}
- (void)getCurrentRoomInfo:(NSString *)roomUid {
NSString * uid= [AccountInfoStorage instance].getUid;
[Api getRoomInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:data.data];
[[self getView] getCurrentRoomInfo:roomInfo];
[[self getView] getCurrentRoomInfoSuccess:roomInfo];
} fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView] getCurrentRoomInfo:nil];
}] uid:roomUid intoUid:@""];
[[self getView] getCurrentRoomInfoSuccess:nil];
}] uid:roomUid intoUid:uid];
}
@end

View File

@@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
///获取下一个个播房成功
- (void)getNextAnchorRoomSuccess:(RoomInfoModel *)roomInfo;
///获取当前房间的信息
- (void)getCurrentRoomInfo:(RoomInfoModel *_Nullable)roomInfo;
- (void)getCurrentRoomInfoSuccess:(RoomInfoModel *_Nullable)roomInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -26,10 +26,6 @@
@property (nonatomic, assign) id<AnchorRoomScrollViewDelegate> anchorScrollDelegate;
@property (nonatomic, strong) UIView *middleImageView;
@property (nonatomic,assign) BOOL isCanScrollTop;
///是不是下一个
@property (nonatomic,assign) BOOL isScrollNext;
///是不是上一个
@property (nonatomic,assign) BOOL isScrollPrevious;
- (instancetype)initWithFrame:(CGRect)frame;

View File

@@ -28,6 +28,7 @@
@implementation AnchorRoomScrollView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
@@ -83,7 +84,6 @@
[self.topDisplayView stopAnimation];
[self.downDisplayView stopAnimation];
self.animatePlay = NO;
NSLog(@"动画结束了");
}
- (void)roomMessageTabelViewStopScroll {
@@ -107,7 +107,6 @@
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
NSLog(@"滚动的Y:%.2f", scrollView.contentOffset.y);
if (scrollView.contentOffset.y > KScreenHeight) {///
if (scrollView.contentOffset.y <= (KScreenHeight * 1.5)) {
return;
@@ -117,15 +116,19 @@
[self startAnimate:self.downDisplayView];
}
} else {///
if (scrollView.contentOffset.y > (KScreenHeight * 0.5)) {
return;
if (self.isCanScrollTop) {
if (scrollView.contentOffset.y > (KScreenHeight * 0.5)) {
return;
}
if (!self.animatePlay) {
[self startAnimate:self.topDisplayView];
}
} else {
///
if (!self.animatePlay) {
[self startAnimate:self.downDisplayView];
}
}
if (!self.animatePlay) {
[self startAnimate:self.topDisplayView];
}
}
}
@@ -148,7 +151,6 @@
}
}
[self stopAnimate];
NSLog(@"scrollViewDidEndDeceleratingY:%.2f", scrollView.contentOffset.y);
}

View File

@@ -440,6 +440,18 @@
}
}
#pragma mark - RoomGuestDelegate
- (void)onRoomChange {
if (self.followAnchorTimer != nil) {
dispatch_source_cancel(self.followAnchorTimer);
}
if (self.trumpetTimer != nil) {
dispatch_source_cancel(self.trumpetTimer);
}
if (self.userGiftTimer != nil) {
dispatch_source_cancel(self.userGiftTimer);
}
}
- (void)onRoomUpdate {
RoomInfoModel * roomInfo = self.delegate.getRoomInfo;
MicroQueueModel * model = [self.delegate.getMicroQueue objectForKey:@"-1"];

View File

@@ -31,6 +31,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)onRoomUpdate;
- (void)onUserUpdate;
- (void)onRoomEntered;
/// 个播 可以切换房间
- (void)onRoomChange;
- (void)onRoomMiniEntered;///最小化进房
- (void)handleNIMNotificationMessage:(NIMMessage *)message;
- (void)handleNIMCustomMessage:(NIMMessage *)message;

View File

@@ -114,7 +114,7 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
///
@property (nonatomic,strong) NSMutableArray<NSString *> *anchorRoomList;
///
@property (nonatomic,assign) BOOL anchorIndex;
@property (nonatomic,assign) NSInteger anchorIndex;
@end
@@ -468,6 +468,7 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
if (!self.stageView.superview) {
[self.anchorScrollView insertSubview:self.stageView belowSubview:self.roomHeaderView];
}
[self.stageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.anchorScrollView.middleImageView);
make.top.mas_equalTo(self.roomHeaderView.mas_bottom);
@@ -780,21 +781,22 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
///)
- (void)getNextAnchorRoomSuccess:(RoomInfoModel *)roomInfo {
self.anchorScrollView.contentOffset = CGPointMake(0, KScreenHeight);
[self hideHUD];
if (roomInfo) { //
NSString * roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
if (![self.anchorRoomList containsObject:[NSString stringWithFormat:@"%ld", roomInfo.uid]]) {
[self.anchorRoomList addObject:roomUid];
if (![self.anchorRoomList containsObject:self.roomUid]) {
[self.anchorRoomList addObject:self.roomUid];
}
self.anchorIndex = self.anchorRoomList.count -1;
//1退
self.anchorScrollView.isCanScrollTop = YES;
self.anchorScrollView.contentOffset = CGPointMake(0, KScreenHeight);
self.isRequestSuperAdmin = NO;
[self exitOldRoom];
[self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]];
[[XPRoomMiniManager shareManager] resetLocalMessage];
[[RtcManager instance] exitRoom];
[self.presenter reportUserOutRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]];
[self.functionView onRoomChange];
//2
[self.backContainerView removeFromSuperview];
[self.stageView removeFromSuperview];
@@ -815,16 +817,19 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
///
[self.presenter getRoomSuperAdmin:self.roomUid];
} else {
if (self.anchorScrollView.isCanScrollTop) {
self.anchorScrollView.contentOffset = CGPointMake(0, KScreenHeight);
} else {
self.anchorScrollView.contentOffset = CGPointMake(0, 0);
}
[self showErrorToast:@"已经到底啦~自动为您返回当前房间"];
}
self.anchorScrollView.isScrollNext = NO;
}
- (void)getCurrentRoomInfo:(RoomInfoModel *)roomInfo {
- (void)getCurrentRoomInfoSuccess:(RoomInfoModel *)roomInfo {
[self hideHUD];
self.anchorScrollView.contentOffset = CGPointMake(0, KScreenHeight);
if (roomInfo && roomInfo.valid) {
//1退
self.isRequestSuperAdmin = NO;
[self exitOldRoom];