张国栋 1 month ago
parent
commit
99274c2d6e

BIN
AICityProperty/AICity.xcworkspace/xcuserdata/zhangguodong.xcuserdatad/UserInterfaceState.xcuserstate


+ 26 - 3
AICityProperty/AICity/JuXing/ViewControllers/JXDetailViewController.m

@@ -18,7 +18,9 @@
 #import "JXCollectionViewController.h"
 #import "JXCommentViewController.h"
 #import <TXLiteAVSDK_Player/TXLiteAVSDK.h>
-@interface JXDetailViewController () <JXSuperPlayerDelegate, UICollectionViewDelegate, UICollectionViewDataSource,JXCollectionViewControllerDelegate,TXVodPlayListener>
+@interface JXDetailViewController () <JXSuperPlayerDelegate, UICollectionViewDelegate, UICollectionViewDataSource,JXCollectionViewControllerDelegate,TXVodPlayListener>{
+    JXSuperPlayer *_currentPlayer;
+}
 
 // 播放器
 @property (nonatomic, strong) UIView *playerContainer;
@@ -43,6 +45,7 @@
 @property (nonatomic, assign) NSInteger currentEpisodeIndex;
 @property (strong, nonatomic) UISlider *videoSlider;
 @property (nonatomic,assign) BOOL isHuadong;
+@property (strong, nonatomic) NSMutableArray *playerList;
 @end
 
 @implementation JXDetailViewController
@@ -184,6 +187,12 @@
     [cell.contentView sendSubviewToBack:playerContainer];
     // 创建播放器
     JXSuperPlayer *player = [[JXSuperPlayer alloc] initWithContainerView:playerContainer];
+//    if (self.playerList.count > indexPath.item) {
+//        JXSuperPlayer *sp = self.playerList[indexPath.item];
+//        [sp releasePlayer];
+//        [self.playerList removeObject:sp];
+//    }
+//    [self.playerList insertObject:player atIndex:indexPath.item];
     player.delegate = self;
     // 右侧互动按钮
     [self setupInteractionButtonsForCell:cell];
@@ -360,8 +369,13 @@
 
 - (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath {
     // 停止不可见的播放器
+    NSLog(@"消失的cell----%d",indexPath.item);
+//    JXSuperPlayer *player = [self.playerList objectAtIndex:indexPath.item];
+//    [player pause];
 }
-
+//- (void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath{
+//    NSLog(@"出现的cell----%d",indexPath.item);
+//}
 - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
     // 获取当前可见的cell索引
     CGFloat pageWidth = scrollView.frame.size.width;
@@ -384,6 +398,10 @@
 //        JXEpisode *episode = self.episodes[currentPage];
 //        JXSuperPlayer *player = [[JXSuperPlayer alloc] initWithContainerView:playerContainer];
 //        player.delegate = self;
+//        if (_currentPlayer) {
+//            [_currentPlayer releasePlayer];
+//        }
+//        _currentPlayer = player;
 //        // 播放视频
 //        [player playWithAppId:episode.appId fileId:episode.fileId psign:episode.psign];
         
@@ -454,5 +472,10 @@
 - (void)dealloc {
     // 停止所有播放器
 }
-
+- (NSMutableArray *)playerList{
+    if (!_playerList) {
+        _playerList = [NSMutableArray array];
+    }
+    return _playerList;
+}
 @end

+ 20 - 1
AICityProperty/AICity/JuXing/Views/JXCommentViewController.m

@@ -182,9 +182,21 @@ static NSString * const kCommentCellIdentifier = @"JXCommentCell";
     [self.inputTextField addTarget:self action:@selector(textFieldDidChange) forControlEvents:UIControlEventEditingChanged];
     [self.inputContainerView addSubview:self.inputTextField];
     
+    self.submitButton = [UIButton buttonWithType:UIButtonTypeCustom];
+    [self.submitButton setTitle:@"发送" forState:UIControlStateNormal];
+    [self.submitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+    [self.submitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateDisabled];
+    self.submitButton.backgroundColor = [UIColor lightGrayColor];
+    self.submitButton.layer.cornerRadius = 20;
+    self.submitButton.enabled = NO;
+    [self.submitButton addTarget:self action:@selector(handleSubmit) forControlEvents:UIControlEventTouchUpInside];
+    [self.inputContainerView addSubview:self.submitButton];
+    
+
     // 约束
     self.inputContainerView.translatesAutoresizingMaskIntoConstraints = NO;
     self.inputTextField.translatesAutoresizingMaskIntoConstraints = NO;
+    self.submitButton.translatesAutoresizingMaskIntoConstraints = NO;
     
     [NSLayoutConstraint activateConstraints:@[
         [self.inputContainerView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
@@ -193,9 +205,16 @@ static NSString * const kCommentCellIdentifier = @"JXCommentCell";
         [self.inputContainerView.heightAnchor constraintEqualToConstant:50],
         
         [self.inputTextField.leadingAnchor constraintEqualToAnchor:self.inputContainerView.leadingAnchor constant:16],
-        [self.inputTextField.rightAnchor constraintEqualToAnchor:self.inputContainerView.rightAnchor constant:-16],
+        [self.inputTextField.rightAnchor constraintEqualToAnchor:self.inputContainerView.rightAnchor constant:-86],
         [self.inputTextField.centerYAnchor constraintEqualToAnchor:self.inputContainerView.centerYAnchor],
         [self.inputTextField.heightAnchor constraintEqualToConstant:40],
+        
+//        [self.submitButton.leadingAnchor constraintEqualToAnchor:self.inputTextField.trailingAnchor constant:8],
+        [self.submitButton.trailingAnchor constraintEqualToAnchor:self.inputContainerView.trailingAnchor constant:-16],
+        [self.submitButton.centerYAnchor constraintEqualToAnchor:self.inputContainerView.centerYAnchor],
+        [self.submitButton.widthAnchor constraintEqualToConstant:60],
+        [self.submitButton.heightAnchor constraintEqualToConstant:40]
+
     ]];
 }