Skip to content

Commit

Permalink
修复 iOS 13 兼容性问题及橫竖屏切换问题
Browse files Browse the repository at this point in the history
  • Loading branch information
shengcui2018 committed Sep 27, 2019
1 parent e94f75f commit 32ade82
Show file tree
Hide file tree
Showing 19 changed files with 341 additions and 189 deletions.
6 changes: 4 additions & 2 deletions Example/Example.xcodeproj/project.pbxproj
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = 5GHU44CJHG;
ENABLE_BITCODE = NO;
Expand All @@ -500,7 +501,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.tencent.fx.Example;
PRODUCT_BUNDLE_IDENTIFIER = com.tencent.SuperPlayer;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "Wildcard Dev";
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -513,6 +514,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
Expand All @@ -522,7 +524,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.tencent.fx.Example;
PRODUCT_BUNDLE_IDENTIFIER = com.tencent.DeviceManageIOSApp.dailybuild;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
2 changes: 1 addition & 1 deletion Example/Example/App/MainTableViewCell.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@property (nonatomic, copy) NSString* title;
@property (nonatomic, copy) NSString* iconName;
@property (nonatomic, copy) NSString* navigateToController;
@property BOOL isUnFold;
@property BOOL expanded;
@property NSArray<CellInfo *> *subCells;

@end
Expand Down
2 changes: 1 addition & 1 deletion Example/Example/App/MainTableViewCell.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ - (void)setCellData:(CellInfo*)cellInfo
[_iconImageView sizeToFit];
_titleLabel.text = cellInfo.title;
[_titleLabel sizeToFit];
self.highLight = _cellData.isUnFold;
self.highLight = _cellData.expanded;

}

Expand Down
103 changes: 57 additions & 46 deletions Example/Example/App/MainViewController.m
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import "MainViewController.h"
#import "MainTableViewCell.h"
#import <SuperPlayer/SuperPlayer.h>
#import <MMLayout/UIView+MMLayout.h>
#import <Masonry/Masonry.h>
#import "TXWeiboListViewController.h"
#import "ViewController.h"
#import "DownloadTableViewController.h"
Expand All @@ -26,7 +26,7 @@ @interface MainViewController ()<
>

@property (nonatomic) NSMutableArray<CellInfo*>* cellInfos;
@property (nonatomic) NSArray<CellInfo*>* addNewCellInfos;
@property (nonatomic) NSArray<CellInfo*>* expandedChildItems;
@property (nonatomic) MainTableViewCell *selectedCell;
@property (nonatomic) UITableView* tableView;
@property (nonatomic) UIView* logUploadView;
Expand Down Expand Up @@ -125,17 +125,20 @@ - (void)initUI
self.view.backgroundColor = RGBA(0x0d,0x0d,0x0d,1);

//大标题
UILabel* lbHeadLine = [[UILabel alloc] initWithFrame:CGRectMake(originX, 50, width, 48)];
lbHeadLine.text = @"超级播放器";
lbHeadLine.textColor = RGBA(0xff, 0xff, 0xff, 1);
lbHeadLine.font = [UIFont systemFontOfSize:24];
[lbHeadLine sizeToFit];
[self.view addSubview:lbHeadLine];
lbHeadLine.mm_center().mm_top(50);

lbHeadLine.userInteractionEnabled = YES;
UILabel* headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(originX, 50, width, 48)];
headerLabel.text = @"超级播放器";
headerLabel.textColor = RGBA(0xff, 0xff, 0xff, 1);
headerLabel.font = [UIFont systemFontOfSize:24];
[headerLabel sizeToFit];
[self.view addSubview:headerLabel];
[headerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.top.equalTo(self.view.mas_top).offset(50);
}];

headerLabel.userInteractionEnabled = YES;
UITapGestureRecognizer* tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
[lbHeadLine addGestureRecognizer:tapGesture];
[headerLabel addGestureRecognizer:tapGesture];

UILongPressGestureRecognizer* pressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; //提取SDK日志暗号!
pressGesture.minimumPressDuration = 2.0;
Expand All @@ -144,41 +147,48 @@ - (void)initUI


//副标题
UILabel* lbSubHead = [[UILabel alloc] initWithFrame:CGRectMake(originX, lbHeadLine.frame.origin.y + lbHeadLine.frame.size.height + 15, width, 30)];
UILabel* footerLabel = [[UILabel alloc] initWithFrame:CGRectMake(originX, headerLabel.frame.origin.y + headerLabel.frame.size.height + 15, width, 30)];
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
lbSubHead.text = [NSString stringWithFormat:@"超级播放器 v%@", version];
lbSubHead.text = [lbSubHead.text stringByAppendingString:@"\n本APP用于展示腾讯视频云终端产品的各类功能"];
lbSubHead.numberOfLines = 2;
lbSubHead.textColor = UIColor.grayColor;
lbSubHead.textAlignment = NSTextAlignmentCenter;
lbSubHead.font = [UIFont systemFontOfSize:14];
lbSubHead.textColor = RGBA(0x53, 0x53, 0x53, 1);
footerLabel.text = [NSString stringWithFormat:@"超级播放器 v%@", version];
footerLabel.text = [footerLabel.text stringByAppendingString:@"\n本APP用于展示腾讯视频云终端产品的各类功能"];
footerLabel.numberOfLines = 2;
footerLabel.textColor = UIColor.grayColor;
footerLabel.textAlignment = NSTextAlignmentCenter;
footerLabel.font = [UIFont systemFontOfSize:14];
footerLabel.textColor = RGBA(0x53, 0x53, 0x53, 1);

//行间距
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:lbSubHead.text];
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:footerLabel.text];
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.alignment = NSTextAlignmentCenter;
[paragraphStyle setLineSpacing:7.5f];//设置行间距
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, lbSubHead.text.length)];
lbSubHead.attributedText = attributedString;

[lbSubHead sizeToFit];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, footerLabel.text.length)];
footerLabel.attributedText = attributedString;

[self.view addSubview:lbSubHead];
lbSubHead.userInteractionEnabled = YES;
[lbSubHead addGestureRecognizer:tapGesture];
lbSubHead.mm_bottom(34).mm__centerX(self.view.mm_centerX);
[footerLabel sizeToFit];

[self.view addSubview:footerLabel];
footerLabel.userInteractionEnabled = YES;
[footerLabel addGestureRecognizer:tapGesture];
[footerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.view).offset(-34);
make.centerX.equalTo(self.view);
}];


//功能列表
int tableviewY = lbSubHead.frame.origin.y + lbSubHead.frame.size.height + 30;
int tableviewY = footerLabel.frame.origin.y + footerLabel.frame.size.height + 30;
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(originX, tableviewY, width, self.view.frame.size.height - tableviewY)];
_tableView.backgroundColor = UIColor.clearColor;
_tableView.delegate = self;
_tableView.dataSource = self;
[self.view addSubview:_tableView];
_tableView.mm_top(lbHeadLine.mm_maxY+12).mm_flexToBottom(0);

[_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.equalTo(self.view);
make.top.equalTo(headerLabel.mas_bottom).offset(12);
make.bottom.equalTo(footerLabel.mas_top).offset(-10);
}];

UIView *view = [UIView new];
view.backgroundColor = [UIColor clearColor];
[_tableView setTableFooterView:view];
Expand Down Expand Up @@ -248,20 +258,21 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
if (cellInfo.subCells != nil) {
[tableView beginUpdates];
NSMutableArray *indexArray = [NSMutableArray new];
if (self.addNewCellInfos) {
NSUInteger deleteFrom = [_cellInfos indexOfObject:self.addNewCellInfos[0]];
for (int i = 0; i < self.addNewCellInfos.count; i++) {
if (self.expandedChildItems) {
// fold previous expanded items
NSUInteger deleteFrom = [_cellInfos indexOfObject:self.expandedChildItems[0]];
for (int i = 0; i < self.expandedChildItems.count; i++) {
[indexArray addObject:[NSIndexPath indexPathForRow:i+deleteFrom inSection:0]];
}
[tableView deleteRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationAutomatic];
[_cellInfos removeObjectsInArray:self.addNewCellInfos];
[_cellInfos removeObjectsInArray:self.expandedChildItems];
}
[tableView endUpdates];

[tableView beginUpdates];
if (!cellInfo.isUnFold) {
if (!cellInfo.expanded) {
self.selectedCell.highLight = NO;
self.selectedCell.cellData.isUnFold = NO;
self.selectedCell.cellData.expanded = NO;

NSUInteger row = [_cellInfos indexOfObject:cellInfo]+1;
[indexArray removeAllObjects];
Expand All @@ -273,13 +284,13 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
[tableView endUpdates];

cellInfo.isUnFold = !cellInfo.isUnFold;
currentCell.highLight = cellInfo.isUnFold;
cellInfo.expanded = !cellInfo.expanded;
currentCell.highLight = cellInfo.expanded;
self.selectedCell = currentCell;
if (cellInfo.isUnFold) {
self.addNewCellInfos = cellInfo.subCells;
if (cellInfo.expanded) {
self.expandedChildItems = cellInfo.subCells;
} else {
self.addNewCellInfos = nil;
self.expandedChildItems = nil;
}
return;
}
Expand Down Expand Up @@ -325,8 +336,8 @@ - (void)handleLongPress:(UILongPressGestureRecognizer *)pressRecognizer

_logUploadView.alpha = 0.1;
[UIView animateWithDuration:0.5 animations:^{
_logUploadView.hidden = NO;
_logUploadView.alpha = 1;
self->_logUploadView.hidden = NO;
self->_logUploadView.alpha = 1;
}];
[_logPickerView reloadAllComponents];
}
Expand All @@ -349,7 +360,7 @@ - (void)onSharedUploadLog:(UIButton*)sender
NSURL *shareobj = [NSURL fileURLWithPath:logPath];
UIActivityViewController *activityView = [[UIActivityViewController alloc] initWithActivityItems:@[shareobj] applicationActivities:nil];
[self presentViewController:activityView animated:YES completion:^{
_logUploadView.hidden = YES;
self->_logUploadView.hidden = YES;
}];
}
}
Expand Down
7 changes: 7 additions & 0 deletions Example/Example/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ @interface AppDelegate ()

@implementation AppDelegate

- (void)clickHelp:(UIButton *)sender {
NSURL *helpUrl = [NSURL URLWithString:@"https://cloud.tencent.com/document/product/454/18871"];
UIApplication *myApp = [UIApplication sharedApplication];
if ([myApp canOpenURL:helpUrl]) {
[myApp openURL:helpUrl];
}
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
Expand Down
21 changes: 21 additions & 0 deletions Example/Example/Assets.xcassets/help_small.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions Example/Example/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
4 changes: 2 additions & 2 deletions Example/Example/LoopPlayViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#import <MMLayout/UIView+MMLayout.h>
#import "Masonry.h"

@interface LoopPlayViewController ()
@interface LoopPlayViewController () <SuperPlayerDelegate>
@property UIView *playerContainer;
@property SuperPlayerView *playerView;
@end
Expand Down Expand Up @@ -47,7 +47,7 @@ - (void)viewDidLoad {
}

- (BOOL)prefersStatusBarHidden {
return YES;
return NO;
}

- (void)superPlayerBackAction:(SuperPlayerView *)player {
Expand Down
Loading

0 comments on commit 32ade82

Please sign in to comment.