Xcode8以及iOS10问题记录

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文件中添加字段,否则会出现闪退的情况

<!-- 相册 --> 
<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性能优化


9.iOS10 UIColor新增方法

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

	+ (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就支持刷新功能

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

- (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)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        // 结束刷新
        [ref endRefreshing];
    });
}


 

11.iOS10判断系统版本

NSLog(@"%zd\n%f\n%@",
          [[[[UIDevice currentDevice] systemVersion] substringToIndex:1] integerValue],
          [[UIDevice currentDevice] systemVersion].floatValue,
          [[UIDevice currentDevice] systemVersion]);





12.UIStatusBar的问题

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



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

@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字段,有以下可以选择的类型:


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来设置

    UILabel *myLabel = [UILabel new];
    // UIFont 的preferredFontForTextStyle:意思是指定一个样式,并让字体大小符合用户设定的字体大小
    myLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
    myLabel.adjustsFontForContentSizeCategory = YES;    // 是否更新字体的变化


  • 9
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值