修复了房间返回按钮可能导致崩溃的问题

This commit is contained in:
fengshuo
2022-12-30 18:13:11 +08:00
parent 7f50ca12f9
commit bf0e4e651f
3 changed files with 34 additions and 18 deletions

View File

@@ -300,14 +300,18 @@
CGFloat scale = image.size.width / image.size.height;
imageView.bounds = CGRectMake(0, 0, 20 * scale, 20);
} else {
NSURL *imgUrl = [NSURL URLWithString:imageUrl];
UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
if (myImage) {
CGFloat scale = myImage.size.width / myImage.size.height;
imageView.bounds = CGRectMake(0, 0, 20 * scale, 20);
} else {
imageView.bounds = CGRectMake(0, 0, 20, 20);
}
dispatch_async(dispatch_get_global_queue(0, 0), ^{
NSURL *imgUrl = [NSURL URLWithString:imageUrl];
UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
dispatch_async(dispatch_get_main_queue(), ^{
if (myImage) {
CGFloat scale = myImage.size.width / myImage.size.height;
imageView.bounds = CGRectMake(0, 0, 20 * scale, 20);
} else {
imageView.bounds = CGRectMake(0, 0, 20, 20);
}
});
});
}
imageView.layer.masksToBounds = YES;
imageView.contentMode = UIViewContentModeScaleAspectFit;

View File

@@ -1492,7 +1492,10 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
[[XPRoomMiniManager shareManager] configRoomInfo:self.roomInfo];
[[XPRoomMiniManager shareManager] configUserInfo:self.userInfo];
[[XPRoomMiniManager shareManager] configCurrentMusic:self.functionView.getCurrentMusic isPlaying:self.functionView.isPlaying];
NSDictionary * dic = @{@"roomInfo":self.roomInfo.model2dictionary, @"userInfo":self.userInfo.model2dictionary, @"microQueue":self.getMicroQueue};
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
[dic safeSetObject:self.roomInfo.model2dictionary forKey:@"roomInfo"];
[dic safeSetObject:self.userInfo.model2dictionary forKey:@"userInfo"];
[dic safeSetObject:self.getMicroQueue forKey:@"microQueue"];
[[NSNotificationCenter defaultCenter] postNotificationName:kRoomMiniNotificationKey object:nil userInfo:dic];
[self.view endEditing:YES];
[self.littleGameView handleSelfInExitEvent];
@@ -1506,7 +1509,10 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
[[XPRoomMiniManager shareManager] configRoomInfo:self.roomInfo];
[[XPRoomMiniManager shareManager] configUserInfo:self.userInfo];
[[XPRoomMiniManager shareManager] configCurrentMusic:self.functionView.getCurrentMusic isPlaying:self.functionView.isPlaying];
NSDictionary * dic = @{@"roomInfo":self.roomInfo.model2dictionary, @"userInfo":self.userInfo.model2dictionary, @"microQueue":self.getMicroQueue};
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
[dic safeSetObject:self.roomInfo.model2dictionary forKey:@"roomInfo"];
[dic safeSetObject:self.userInfo.model2dictionary forKey:@"userInfo"];
[dic safeSetObject:self.getMicroQueue forKey:@"microQueue"];
[[NSNotificationCenter defaultCenter] postNotificationName:kRoomMiniNotificationKey object:nil userInfo:dic];
[self.view endEditing:YES];
[self.littleGameView handleSelfInExitEvent];
@@ -1518,7 +1524,10 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
[[XPRoomMiniManager shareManager] configRoomInfo:self.roomInfo];
[[XPRoomMiniManager shareManager] configUserInfo:self.userInfo];
[[XPRoomMiniManager shareManager] configCurrentMusic:self.functionView.getCurrentMusic isPlaying:self.functionView.isPlaying];
NSDictionary * dic = @{@"roomInfo":self.roomInfo.model2dictionary, @"userInfo":self.userInfo.model2dictionary, @"microQueue":self.getMicroQueue};
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
[dic safeSetObject:self.roomInfo.model2dictionary forKey:@"roomInfo"];
[dic safeSetObject:self.userInfo.model2dictionary forKey:@"userInfo"];
[dic safeSetObject:self.getMicroQueue forKey:@"microQueue"];
[[NSNotificationCenter defaultCenter] postNotificationName:kRoomMiniNotificationKey object:nil userInfo:dic];
[self.view endEditing:YES];
[self handleFirstOutRoom];

View File

@@ -301,13 +301,16 @@ NSString * const kProhibitRightSlip = @"prohibitRightSlip";
} else if ([message.name isEqualToString:kJSOpenRoom]) {
NSString *uid = [NSString stringWithFormat:@"%@",message.body];
if (uid.length > 0) {
UIViewController * controller = [XCCurrentVCStackManager shareManager].getCurrentVC;
if ([controller isKindOfClass:[XPRoomViewController class]]) {
XPRoomViewController<RoomHostDelegate> * rooomVC = controller;
[rooomVC exitRoom];
[TTPopup dismiss];
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[XPRoomViewController class]]) {
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController popToRootViewControllerAnimated:NO];
XPRoomViewController<RoomHostDelegate> * rooomVC = obj;
[TTPopup dismiss];
[rooomVC exitRoom];
*stop = YES;
}
}];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[XPRoomViewController openRoom:uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
});
}