From 1ce16bae62c8d48ef2e34ef92fbe977e908ea6a5 Mon Sep 17 00:00:00 2001 From: fengshuo <963787902@qq.com> Date: Wed, 14 Sep 2022 19:14:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=88=BF=E9=97=B4?= =?UTF-8?q?=E5=8D=8A=E5=B1=8F=E7=A7=81=E8=81=8A=E5=B4=A9=E6=BA=83=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xplan-ios/Base/UI/XCCurrentVCStackManager.m | 19 +----- .../View/Session/SessionViewController.m | 17 +++++ .../SessionList/SessionListViewController.h | 3 + .../SessionList/SessionListViewController.m | 23 +++++-- .../Friend/XPMineAttentionViewController.h | 2 + .../Friend/XPMineAttentionViewController.m | 9 ++- .../View/Friend/XPMineContactViewController.m | 9 +++ .../View/Friend/XPMineFansViewController.h | 2 + .../View/Friend/XPMineFansViewController.m | 9 ++- .../View/Friend/XPMineFriendViewController.h | 2 + .../View/Friend/XPMineFriendViewController.m | 11 ++++ .../Mine/View/Friend/XPRoomHalfMessageView.h | 3 + .../Mine/View/Friend/XPRoomHalfMessageView.m | 64 ++++++++++--------- .../XPRoomFunctionContainerView.m | 5 +- .../XPRoomMenuContainerView.m | 10 +-- .../UserCard/View/XPUserCardViewController.m | 5 +- 16 files changed, 134 insertions(+), 59 deletions(-) diff --git a/xplan-ios/Base/UI/XCCurrentVCStackManager.m b/xplan-ios/Base/UI/XCCurrentVCStackManager.m index 039cb100..84fb0875 100644 --- a/xplan-ios/Base/UI/XCCurrentVCStackManager.m +++ b/xplan-ios/Base/UI/XCCurrentVCStackManager.m @@ -7,6 +7,8 @@ // #import "XCCurrentVCStackManager.h" + +NSString * const kRoomChatPushViewKey = @"kRoomChatPushViewKey"; @implementation XCCurrentVCStackManager + (instancetype)shareManager { @@ -21,22 +23,7 @@ - (UIViewController *)getCurrentVC { ///兼容房间内私聊的 - UIWindow * currentWindow; - for (int i = 0; i < [UIApplication sharedApplication].windows.count; i++) { - UIWindow * window = [[UIApplication sharedApplication].windows objectAtIndex:i]; - if(window.tag == 1000) { - currentWindow = window; - break; - } - } - if (currentWindow) { - [currentWindow resignKeyWindow]; - [currentWindow.rootViewController.navigationController popViewControllerAnimated:YES]; - [currentWindow.superview removeFromSuperview]; - currentWindow.rootViewController = nil; - currentWindow.windowLevel = -1; - currentWindow = nil; - } + [[NSNotificationCenter defaultCenter] postNotificationName:kRoomChatPushViewKey object:nil]; UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController; UIViewController *currentVC = [self getCurrentVCFrom:rootViewController]; diff --git a/xplan-ios/Main/Message/View/Session/SessionViewController.m b/xplan-ios/Main/Message/View/Session/SessionViewController.m index 72ee8185..a627c23f 100644 --- a/xplan-ios/Main/Message/View/Session/SessionViewController.m +++ b/xplan-ios/Main/Message/View/Session/SessionViewController.m @@ -179,6 +179,12 @@ } } +- (void)viewDidLayoutSubviews{ + if (self.openType == SessionListOpenTypeRoom) { + self.view.frame = CGRectMake(0, 0, KScreenWidth, kHalfScreenHeight); + } +} + - (void)initData { NIMUser * user = [[NIMSDK sharedSDK].userManager userInfo:self.session.sessionId]; if (user) { @@ -314,6 +320,17 @@ } - (void)sessionNavView:(SessionNavView *)view didClickBack:(UIButton *)sender { + if (self.openType == SessionListOpenTypeRoom) { + CATransition *transition = [CATransition animation]; + transition.duration = 0.3f; + transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; + transition.type = kCATransitionPush; + transition.subtype = kCATransitionFromLeft; + [self.view.superview.layer addAnimation:transition forKey:nil]; + [self removeFromParentViewController]; + [self.view removeFromSuperview]; + return; + } [self.navigationController popViewControllerAnimated:YES]; } diff --git a/xplan-ios/Main/Message/View/SessionList/SessionListViewController.h b/xplan-ios/Main/Message/View/SessionList/SessionListViewController.h index f55ce5ef..8cf075cd 100644 --- a/xplan-ios/Main/Message/View/SessionList/SessionListViewController.h +++ b/xplan-ios/Main/Message/View/SessionList/SessionListViewController.h @@ -21,6 +21,9 @@ typedef NS_ENUM(NSUInteger, SessionListOpenType) { @interface SessionListViewController : BaseViewController - (instancetype)initWithType:(SessionListOpenType)type; +/** 控制器 因为房间内聊天没有控制器去push 或者做其他的操作*/ +@property (nonatomic, weak) UIViewController * mainController; + @end diff --git a/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m b/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m index 17d2053e..b4773e92 100644 --- a/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m +++ b/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m @@ -161,11 +161,26 @@ NSString * const kMessageShowReadDotKey = @"kMessageShowReadDotKey"; [self.navigationController pushViewController:findNewVC animated:YES]; return; } + [tableView deselectRowAtIndexPath:indexPath animated:YES]; - NIMRecentSession *recentSession = self.recentSessions[indexPath.row]; - SessionViewController *vc = [[SessionViewController alloc] initWithSession:recentSession.session]; - vc.openType = self.openType; - [self.navigationController pushViewController:vc animated:YES]; + if (self.openType == SessionListOpenTypeRoom) { + NIMRecentSession *recentSession = self.recentSessions[indexPath.row]; + SessionViewController * sessionVC =[[SessionViewController alloc] initWithSession:recentSession.session]; + sessionVC.openType = self.openType; + CATransition *transition = [CATransition animation]; + transition.duration = 0.3f; + transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; + transition.type = kCATransitionPush; + transition.subtype = kCATransitionFromRight; + [self.mainController.view.layer addAnimation:transition forKey:nil]; + [self.mainController.view addSubview:sessionVC.view]; + [self.mainController addChildViewController:sessionVC]; + } else { + NIMRecentSession *recentSession = self.recentSessions[indexPath.row]; + SessionViewController *vc = [[SessionViewController alloc] initWithSession:recentSession.session]; + vc.openType = self.openType; + [self.navigationController pushViewController:vc animated:YES]; + } } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.h b/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.h index 6030c5c2..4ccd3ab9 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.h +++ b/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.h @@ -21,6 +21,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic,assign) ContactUseingType type; ///代理 @property (nonatomic,weak) id delegate; +/** 控制器 因为房间内聊天没有控制器去push 或者做其他的操作*/ +@property (nonatomic, weak) UIViewController * mainController; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.m b/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.m index 9e0c120f..f0aedb69 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.m +++ b/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.m @@ -163,7 +163,14 @@ if (self.type == ContactUseingType_In_Room) { SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:[NIMSession session:fansInfoModel.uid type:NIMSessionTypeP2P]]; sessionVC.openType = SessionListOpenTypeRoom; - [self.navigationController pushViewController:sessionVC animated:YES]; + CATransition *transition = [CATransition animation]; + transition.duration = 0.3f; + transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; + transition.type = kCATransitionPush; + transition.subtype = kCATransitionFromRight; + [self.mainController.view.layer addAnimation:transition forKey:nil]; + [self.mainController addChildViewController:sessionVC]; + [self.mainController.view addSubview:sessionVC.view]; } else if(self.type == ContactUseingType_Share){ if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineAttentionViewController:didSelectItem:)]) { [self.delegate xPMineAttentionViewController:self didSelectItem:fansInfoModel]; diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineContactViewController.m b/xplan-ios/Main/Mine/View/Friend/XPMineContactViewController.m index d1fda5cd..df0a9af4 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPMineContactViewController.m +++ b/xplan-ios/Main/Mine/View/Friend/XPMineContactViewController.m @@ -58,6 +58,7 @@ - (void)initSubViews { [self.view addSubview:self.titleView]; [self.view addSubview:self.listContainerView]; + } - (void)initSubViewConstraints { @@ -81,12 +82,16 @@ // 根据下标 index 返回对应遵守并实现 `JXCategoryListContentViewDelegate` 协议的列表实例 - (id)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index { if (index == 0) { +// [self addChildViewController:self.sessionListVC]; return self.sessionListVC; }else if (index == 1) { +// [self addChildViewController:self.friendVC]; return self.friendVC; } else if(index == 2) { +// [self addChildViewController:self.fansVC]; return self.fansVC; } else { +// [self addChildViewController:self.attentionVC]; return self.attentionVC; } } @@ -139,6 +144,7 @@ - (SessionListViewController *)sessionListVC { if (!_sessionListVC) { _sessionListVC = [[SessionListViewController alloc] initWithType:SessionListOpenTypeRoom]; + _sessionListVC.mainController = self; } return _sessionListVC; } @@ -147,6 +153,7 @@ if (!_attentionVC) { _attentionVC = [[XPMineAttentionViewController alloc] init]; _attentionVC.type = ContactUseingType_In_Room; + _attentionVC.mainController = self; } return _attentionVC; } @@ -155,6 +162,7 @@ if (!_friendVC) { _friendVC = [[XPMineFriendViewController alloc] init]; _friendVC.type = ContactUseingType_In_Room; + _friendVC.mainController = self; } return _friendVC; } @@ -163,6 +171,7 @@ if (!_fansVC) { _fansVC = [[XPMineFansViewController alloc] init]; _fansVC.type = ContactUseingType_In_Room; + _fansVC.mainController = self; } return _fansVC; } diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.h b/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.h index 5d1a4b9d..f838dcb5 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.h +++ b/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.h @@ -21,6 +21,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic,assign) ContactUseingType type; ///代理 @property (nonatomic,weak) id delegate; +/** 控制器 因为房间内聊天没有控制器去push 或者做其他的操作*/ +@property (nonatomic, weak) UIViewController * mainController; @end diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.m b/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.m index 5dc98853..9daf4657 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.m +++ b/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.m @@ -173,7 +173,14 @@ if (self.type == ContactUseingType_In_Room) { SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:[NIMSession session:fansInfoModel.uid type:NIMSessionTypeP2P]]; sessionVC.openType = SessionListOpenTypeRoom; - [self.navigationController pushViewController:sessionVC animated:YES]; + CATransition *transition = [CATransition animation]; + transition.duration = 0.3f; + transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; + transition.type = kCATransitionPush; + transition.subtype = kCATransitionFromRight; + [self.mainController.view.layer addAnimation:transition forKey:nil]; + [self.mainController addChildViewController:sessionVC]; + [self.mainController.view addSubview:sessionVC.view]; } else if(self.type == ContactUseingType_Share) { if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineFansViewController:didSelectItem:)]) { [self.delegate xPMineFansViewController:self didSelectItem:fansInfoModel]; diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.h b/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.h index b6d6a0f1..606909c5 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.h +++ b/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.h @@ -20,6 +20,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic,assign) ContactUseingType type; ///代理 @property (nonatomic,weak) id delegate; +/** 控制器 因为房间内聊天没有控制器去push 或者做其他的操作*/ +@property (nonatomic, weak) UIViewController * mainController; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.m b/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.m index 4f7cf251..5583dba0 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.m +++ b/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.m @@ -104,6 +104,17 @@ if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineFriendViewController:didSelectItem:)]) { [self.delegate xPMineFriendViewController:self didSelectItem:userInfo]; } + } else if(self.type == ContactUseingType_In_Room) { + SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:[NIMSession session:[NSString stringWithFormat:@"%ld", userInfo.uid] type:NIMSessionTypeP2P]]; + sessionVC.openType = SessionListOpenTypeRoom; + CATransition *transition = [CATransition animation]; + transition.duration = 0.3f; + transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; + transition.type = kCATransitionPush; + transition.subtype = kCATransitionFromRight; + [self.mainController.view.layer addAnimation:transition forKey:nil]; + [self.mainController addChildViewController:sessionVC]; + [self.mainController.view addSubview:sessionVC.view]; } else { SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:[NIMSession session:[NSString stringWithFormat:@"%ld", userInfo.uid] type:NIMSessionTypeP2P]]; sessionVC.openType = SessionListOpenTypeRoom; diff --git a/xplan-ios/Main/Mine/View/Friend/XPRoomHalfMessageView.h b/xplan-ios/Main/Mine/View/Friend/XPRoomHalfMessageView.h index 55ef3253..499190e1 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPRoomHalfMessageView.h +++ b/xplan-ios/Main/Mine/View/Friend/XPRoomHalfMessageView.h @@ -12,6 +12,9 @@ NS_ASSUME_NONNULL_BEGIN @interface XPRoomHalfMessageView : UIView ///私聊的用户ID @property (nonatomic,copy) NSString *chatUserId; + + +- (instancetype)initWithFrame:(CGRect)frame controller:(UIViewController *)controller; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/Friend/XPRoomHalfMessageView.m b/xplan-ios/Main/Mine/View/Friend/XPRoomHalfMessageView.m index 981f9916..ccaecdd7 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPRoomHalfMessageView.m +++ b/xplan-ios/Main/Mine/View/Friend/XPRoomHalfMessageView.m @@ -10,43 +10,69 @@ #import #import "XPMacro.h" #import "BaseNavigationController.h" +#import "XCCurrentVCStackManager.h" ///View #import "XPMineContactViewController.h" +UIKIT_EXTERN NSString * kRoomChatPushViewKey; + @interface XPRoomHalfMessageView () ///点击消失的View @property (nonatomic,strong) UIView *dismissView; -///消息的容器 -@property (nonatomic,strong) UIWindow *messageWindow; ///联系人的VC @property (nonatomic,strong) XPMineContactViewController *contactVC; +@property (nonatomic,weak) UIViewController *roomVC; @end @implementation XPRoomHalfMessageView +- (void)dealloc { + NSLog(@"aaaaa"); +} - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.tag = 888; [self initSubViews]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismissViewTap) name:kRoomChatPushViewKey object:nil]; + } + return self; +} + +- (instancetype)initWithFrame:(CGRect)frame controller:(UIViewController *)controller { + self = [super initWithFrame:frame]; + if (self) { + self.tag = 888; + self.roomVC = controller; + [self initSubViews]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismissViewTap) name:kRoomChatPushViewKey object:nil]; } return self; } #pragma mark - Private Method - (void)initSubViews { + XPMineContactViewController * vc=[XPMineContactViewController new]; + CAShapeLayer * layer = [CAShapeLayer layer]; + UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, KScreenWidth, kHalfScreenHeight) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(12, 12)]; + layer.path = path.CGPath; + vc.view.layer.masksToBounds = YES; + vc.view.layer.mask = layer;; + vc.view.frame = CGRectMake(0, KScreenHeight - kHalfScreenHeight, KScreenWidth, kHalfScreenHeight); + self.contactVC = vc; + + [self addSubview:self.dismissView]; - [self addSubview:self.messageWindow]; + [self addSubview:self.contactVC.view]; + [self.roomVC addChildViewController:vc]; } #pragma mark - Event Response - (void)dismissViewTap { [self removeFromSuperview]; - self.messageWindow.rootViewController = nil; - self.messageWindow.windowLevel = -1; - self.messageWindow = nil; - [[NSNotificationCenter defaultCenter] postNotificationName:@"roomMessageTabelViewStopScroll" object:nil]; + self.contactVC = nil; +// [[NSNotificationCenter defaultCenter] postNotificationName:@"roomMessageTabelViewStopScroll" object:nil]; } #pragma mark - Getters And Setters @@ -55,6 +81,8 @@ self.contactVC.chatUserId = chatUserId; } + + - (UIView *)dismissView { if (!_dismissView) { _dismissView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight - kHalfScreenHeight)]; @@ -65,26 +93,4 @@ } return _dismissView; } - -- (UIWindow *)messageWindow { - if (!_messageWindow) { - //创建测试导航器以及vc - XPMineContactViewController * vc=[XPMineContactViewController new]; - self.contactVC = vc; - BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:vc]; - //创建window,并将window的坐标设置在屏幕底部,设置windowLevel防止获取默认window失败 - UIWindow *testWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0, KScreenHeight - kHalfScreenHeight, KScreenWidth, kHalfScreenHeight)]; - CAShapeLayer * layer = [CAShapeLayer layer]; - UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, KScreenWidth, kHalfScreenHeight) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(12, 12)]; - layer.path = path.CGPath; - testWindow.layer.masksToBounds = YES; - testWindow.layer.mask = layer;; - testWindow.windowLevel = UIWindowLevelAlert; - testWindow.rootViewController = nav; - testWindow.hidden = NO; - testWindow.tag = 1000; - _messageWindow = testWindow; - } - return _messageWindow; -} @end diff --git a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m index a8bcbf39..5c5037c4 100644 --- a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m +++ b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m @@ -354,8 +354,9 @@ } - (void)xPRoomNewUserGreetView:(XPRoomNewUserGreetView *)view didClickCheckout:(UIButton *)sender { - XPRoomHalfMessageView *halfMessageView = [[XPRoomHalfMessageView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight)]; - [[UIApplication sharedApplication].delegate.window addSubview:halfMessageView]; + UIViewController * controller = (UIViewController *)self.delegate; + XPRoomHalfMessageView *halfMessageView = [[XPRoomHalfMessageView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight) controller:controller]; + [controller.view addSubview:halfMessageView]; [UIView animateWithDuration:.35 animations:^{ CGRect rect = halfMessageView.frame; rect.origin.y = 0; diff --git a/xplan-ios/Main/Room/View/MenuContainerView/XPRoomMenuContainerView.m b/xplan-ios/Main/Room/View/MenuContainerView/XPRoomMenuContainerView.m index 724d3a72..96b4c455 100644 --- a/xplan-ios/Main/Room/View/MenuContainerView/XPRoomMenuContainerView.m +++ b/xplan-ios/Main/Room/View/MenuContainerView/XPRoomMenuContainerView.m @@ -130,8 +130,9 @@ break; case XPRoomMenuItemType_Message: { - XPRoomHalfMessageView *halfMessageView = [[XPRoomHalfMessageView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight)]; - [[UIApplication sharedApplication].delegate.window addSubview:halfMessageView]; + UIViewController * controller = (UIViewController *)self.delegate; + XPRoomHalfMessageView *halfMessageView = [[XPRoomHalfMessageView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight) controller:controller]; + [controller.view addSubview:halfMessageView]; [UIView animateWithDuration:.35 animations:^{ CGRect rect = halfMessageView.frame; rect.origin.y = 0; @@ -419,9 +420,10 @@ #pragma mark - XPRoomMessageBubbleViewDelegate - (void)xPRoomMessageBubbleView:(XPRoomMessageBubbleView *)view didSelectSession:(NIMRecentSession *)session { - XPRoomHalfMessageView *halfMessageView = [[XPRoomHalfMessageView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight)]; + UIViewController * controller = (UIViewController *)self.delegate; + XPRoomHalfMessageView *halfMessageView = [[XPRoomHalfMessageView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight) controller:controller]; halfMessageView.chatUserId = session.session.sessionId; - [[UIApplication sharedApplication].delegate.window addSubview:halfMessageView]; + [controller.view addSubview:halfMessageView]; [UIView animateWithDuration:.35 animations:^{ CGRect rect = halfMessageView.frame; rect.origin.y = 0; diff --git a/xplan-ios/Main/Room/View/UserCard/View/XPUserCardViewController.m b/xplan-ios/Main/Room/View/UserCard/View/XPUserCardViewController.m index fbdde706..f898b168 100644 --- a/xplan-ios/Main/Room/View/UserCard/View/XPUserCardViewController.m +++ b/xplan-ios/Main/Room/View/UserCard/View/XPUserCardViewController.m @@ -739,9 +739,10 @@ case UserCardItemType_Chat: { [self dismissViewControllerAnimated:YES completion:^{ - XPRoomHalfMessageView *halfMessageView = [[XPRoomHalfMessageView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight)]; + UIViewController * controller = (UIViewController *)self.cardInfo.delegate; + XPRoomHalfMessageView *halfMessageView = [[XPRoomHalfMessageView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight) controller:controller]; halfMessageView.chatUserId = self.cardInfo.uid; - [[UIApplication sharedApplication].delegate.window addSubview:halfMessageView]; + [controller.view addSubview:halfMessageView]; [UIView animateWithDuration:.35 animations:^{ CGRect rect = halfMessageView.frame; rect.origin.y = 0;