您的位置:首页 > 移动开发 > IOS开发

Xcode8以及iOS10问题记录

2017-05-23 11:20 447 查看


Xcode8以及iOS10问题记录

分类:iOS项目开发

(5122) (2) 举报 收藏


1.解决工程中输出无关日志

Edit
Scheme -> Run -> Arguments, 在Environment Variables里边添加
OS_ACTIVITY_MODE disable



遗留问题:

还会出现下面这个问题

5]:
Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x112b58910)
and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x112982210). One of the two will be used. Which one
is undefined.


2.注释快捷键⌘+/失效

重启电脑,如果还不能使用的话就启用命令工具(命令运行 sudo
/usr/libexec/xpccachectl),然后重启电脑


3.对于插件无法使用

网上推荐的是将Xcode拷贝一份可以使用插件的Xcode(在应用程序中),但是这个Xcode不能打包上传等,建议不要使用这种方法

三方插件解决方法(fix
method):让你的Xcode8继续使用插件


4.iOS10隐私权限问题

iOS10中调用相机相册等系统功能时,需要在info.plist文件中添加字段,否则会出现闪退的情况

[html] view
plain copy







<!-- 相册 -->

<key>NSPhotoLibraryUsageDescription</key>

<string>App需要您的同意,才能访问相册</string>

<!-- 相机 -->

<key>NSCameraUsageDescription</key>

<string>App需要您的同意,才能访问相机</string>

<!-- 麦克风 -->

<key>NSMicrophoneUsageDescription</key>

<string>App需要您的同意,才能访问麦克风</string>

<!-- 位置 -->

<key>NSLocationUsageDescription</key>

<string>App需要您的同意,才能访问位置</string>

<!-- 在使用期间访问位置 -->

<key>NSLocationWhenInUseUsageDescription</key>

<string>App需要您的同意,才能在使用期间访问位置</string>

<!-- 始终访问位置 -->

<key>NSLocationAlwaysUsageDescription</key>

<string>App需要您的同意,才能始终访问位置</string>

<!-- 日历 -->

<key>NSCalendarsUsageDescription</key>

<string>App需要您的同意,才能访问日历</string>

<!-- 提醒事项 -->

<key>NSRemindersUsageDescription</key>

<string>App需要您的同意,才能访问提醒事项</string>

<!-- 运动与健身 -->

<key>NSMotionUsageDescription</key> <string>App需要您的同意,才能访问运动与健身</string>

<!-- 健康更新 -->

<key>NSHealthUpdateUsageDescription</key>

<string>App需要您的同意,才能访问健康更新 </string>

<!-- 健康分享 -->

<key>NSHealthShareUsageDescription</key>

<string>App需要您的同意,才能访问健康分享</string>

<!-- 蓝牙 -->

<key>NSBluetoothPeripheralUsageDescription</key>

<string>App需要您的同意,才能访问蓝牙</string>

<!-- 媒体资料库 -->

<key>NSAppleMusicUsageDescription</key>

<string>App需要您的同意,才能访问媒体资料库</string>

iOS10 配置须知




5.label中的文字显示不全

Xcode8与Xcode7.3的文字宽度变化(英文字母没有问题,只有汉字有问题)




6.Notification(通知)

(1)所有相关通知被统一到了UserNotifications.framework框架中

(2)增加了撤销、更新、中途还可以修改通知的内容

(3)通知不再是简单的文本,现在还可以是图片、视频,自定义通知的展示等等

(4)iOS10相对之前的通知来说更好用更易于管理,并且进行了大规模优化

(5)iOS10之后,本地与远程通知集成在一个方法中


7.ATS问题

iOS10从2017年1月1日起只能使用HTTPS,否则提交App可能会被拒绝。


8.iOS10中UICollectionView性能优化

WWDC2016
Session笔记 - iOS 10 UICollectionView新特性


9.iOS10
UIColor新增方法

iOS10苹果建议我们使用sRGB,因为它性能更好,色彩更丰富。

[html] view
plain copy







+ (UIColor *)colorWithDisplayP3Red:(CGFloat)displayP3Red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha NS_AVAILABLE_IOS(10_0);

- (UIColor *)initWithDisplayP3Red:(CGFloat)displayP3Red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha NS_AVAILABLE_IOS(10_0);


10.iOS10
UIScrollView新增refreshControl

也就是说以后只要是继承UIScrollView就支持刷新功能

[html] view
plain copy







@property (nonatomic, strong, nullable) UIRefreshControl *refreshControl NS_AVAILABLE_IOS(10_0) __TVOS_PROHIBITED;

[objc] view
plain copy







- (void)viewDidLoad {

[super viewDidLoad];

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 500)];

scrollView.backgroundColor = [UIColor redColor];

scrollView.contentSize = CGSizeMake(self.view.bounds.size.width, 1000);

[self.view addSubview:scrollView];

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1"]];

[scrollView addSubview:imageView];

// 添加下拉刷新控件

UIRefreshControl *ref = [[UIRefreshControl alloc] init];

// 监听刷新方法

[ref addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];

scrollView.refreshControl = ref;

self.view.backgroundColor = [UIColor redColor];

}

- (void)refresh:(UIRefreshControl *)ref {

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(22 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

// 结束刷新

[ref endRefreshing];

});

}






11.iOS10判断系统版本

[html] view
plain copy







NSLog(@"%zd\n%f\n%@",

[[[[UIDevice currentDevice] systemVersion] substringToIndex:1] integerValue],

[[UIDevice currentDevice] systemVersion].floatValue,

[[UIDevice currentDevice] systemVersion]);




12.UIStatusBar的问题

在iOS10中,如果还是用以前设置UIStatusBar类型或者控制隐藏还是显示的方法,会报警告,方法过期,如下图:



要想修改UIStatusBar的样式或者状态使用下图中所示的属性或方法:

[html] view
plain copy







@property(nonatomic, readonly) UIStatusBarStyle preferredStatusBarStyle NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to UIStatusBarStyleDefault

@property(nonatomic, readonly) BOOL prefersStatusBarHidden NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to NO

- (UIStatusBarStyle)preferredStatusBarStyle NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to UIStatusBarStyleDefault

- (BOOL)prefersStatusBarHidden NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to NO

// Override to return the type of animation that should be used for status bar changes for this view controller. This currently only affects changes to prefersStatusBarHidden.

- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation NS_AVAILABLE_IOS(7_0) __TVOS_PROHIBITED; // Defaults to UIStatusBarAnimationFade


13.UITextField新增字段

在iOS10中,UITextField新增了textContentType字段,是UITextContentType类型,它是一个枚举,作用是可以指定输入框的类型,以便系统可以分析出用户的语义,是电话类型就建议一些电话,是地址类型就建议一些地址。可以在#import<UIkit/UITextInputTraits.h>文件中,查看textContentType字段,有以下可以选择的类型:

[html] view
plain copy







UIKIT_EXTERN UITextContentType const UITextContentTypeName NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeNamePrefix NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeGivenName NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeMiddleName NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeFamilyName NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeNameSuffix NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeNickname NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeJobTitle NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeOrganizationName NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeLocation NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeFullStreetAddress NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeStreetAddressLine1 NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeStreetAddressLine2 NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeAddressCity NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeAddressState NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeAddressCityAndState NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeSublocality NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeCountryName NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypePostalCode NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeTelephoneNumber NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeEmailAddress NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeURL NS_AVAILABLE_IOS(10_0);

UIKIT_EXTERN UITextContentType const UITextContentTypeCreditCardNumber NS_AVAILABLE_IOS(10_0);


14.推送

所有的推送平台,不管是极光还是什么的,要想收到推送,这个必须打开




15.蓝牙相关

CBCentralManagerState废弃,使用CBManagerState替代

CBCentralManager直接继承于CBManager,里面直接声明的属性:

@property(nonatomic, assign, readonly) CBManagerState state;


16.openURL的方法被遗弃,使用其替换方法

openURL:options:completionHandler:


17.iOS10字体随着手机系统字体而改变

iOS
10提供了这样的属性adjustsFontForContentSizeCategory来设置

[html] view
plain copy







UILabel *myLabel = [UILabel new];

// UIFont 的preferredFontForTextStyle:意思是指定一个样式,并让字体大小符合用户设定的字体大小

myLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];

myLabel.adjustsFontForContentSizeCategory = YES; // 是否更新字体的变化



原文地址 http://blog.csdn.net/floatingdreamsh/article/details/52605346
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  xcode