iOS10添加了新的权限控制范围 如果你尝试访问这些隐私数据时得到如下错误:
> This app has crashed because it attempted to access privacy-sensitive
> data without a usage description. The app's Info.plist must contain
> an NSCameraUsageDescription key with a string value explaining to the
> user how the app uses this data
因为它企图访问敏感数据时没有在应用程序的Info.plist 设置privacy key 新增的privacy setting如下:
更新Xcode 8 如果控制台出现 enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0
enable_oversize: 可通过如下方法设置:
Edit Scheme-> Run -> Arguments,
在Environment Variables里边添加
OS_ACTIVITY_MODE = Disable
iOS10 在一个控件上调用layoutIfNeed
是只会单独计算约束,它所约束的控件不会生效,想要达到之前的效果需要在父级控件上调用layoutIfNeed
Swift3.0会将oc的NSDate
转为Data
类型,有些操作NSDate
的第三方库会闪退
Swift3.0字符串类型的通知常量被定义为struct
static let MyGreatNotification = Notification.Name("MyGreatNotification")// Use site (no change)
NotificationCenter.default().post(name: MyController.MyGreatNotification, object: self)'
在Swift3.0 Zip2Sequence(_:_:)
方法被替换为zip(_:_:)
在Swift3.0 Range<>.reversed
方法被移除,被替换为<Collection>[<Range>].indices.reversed().
var array = ["A","B","C","D"]for i in array.indices.reversed() { print("\(i)")
}输出:3 2 1 0
Range
CountableRange
ClosedRange
CountableClosedRange
不同的表达式会生成不同的Range
var countableRange = 0..<20 'CountableRange(0..<20)'var countableClosedRange = 0...20 'CountableClosedRange(0...20)'
Index的successor(), predecessor(), advancedBy(_:), advancedBy(_:limit:), or distanceTo(_:)
方法被移除,这些操作被移动到Collection
myIndex.successor() => myCollection.index(after: myIndex)
myIndex.predecessor() => myCollection.index(before: myIndex)
myIndex.advance(by: …) => myCollection.index(myIndex, offsetBy: …)
如果你需要操作UIStatusBar,在iOS10需要改为
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleDefault;
}
在iOS10 UICollectionView 最大的改变是增加了Pre-Fetching(预加载), 如果你翻看UICollectionView的最新API你可以发现新增了如下属性:
@property (nonatomic, weak, nullable) id<UICollectionViewDataSourcePrefetching> prefetchDataSource@property (nonatomic, getter=isPrefetchingEnabled) BOOL
在iOS10 Pre-Fetching 是默认开启的,如果出于某些原因你不想开启Pre-Fetching,可以通过如下设置禁用:
collectionView.isPrefetchingEnabled = false
UICollectionViewDataSourcePrefetching协议定义如下:
@protocol UICollectionViewDataSourcePrefetching <NSObject>
@required
// indexPaths are ordered ascending by geometric distance from the collection view
- (void)collectionView:(UICollectionView *)collectionView prefetchItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths NS_AVAILABLE_IOS(10_0);@optional
// indexPaths that previously were considered as candidates for pre-fetching, but were not actually used; may be a subset of the previous call to -collectionView:prefetchItemsAtIndexPaths:
- (void)collectionView:(UICollectionView *)collectionView cancelPrefetchingForItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths NS_AVAILABLE_IOS(10_0);@end
和UICollectionView一样UITableView也增加了Pre-Fetching技术,UITableView新增了如下属性:
@property (nonatomic, weak) id<UITableViewDataSourcePrefetching> prefetchDataSource NS_AVAILABLE_IOS(10_0);
奇怪的是UITableView并没有找到 isPrefetchingEnabled
属性的定义
UIScrollView
新增了refreshControl
属性
@property (nonatomic, strong, nullable) UIRefreshControl *refreshControl NS_AVAILABLE_IOS(10_0) __TVOS_PROHIBITED;
这意味着 UICollectionView
和UITableView
都支持refresh功能了。
我们也可以脱离UITableViewController
使用UIRefreshControl
了。
目前有如下访问级别:
Swift3.0开始我们将能使用除inout var let关键字作为参数标签
// Swift 3 calling with argument label:
calculateRevenue(for sales: numberOfCopies,
in .dollars) // Swift 3 declaring with argument label:
calculateRevenue(for sales: Int,
in currency: Currency) func touchesMatching(phase: NSTouchPhase, in view: NSView?) -> Set<NSTouch>
如果你坚持要使用inout var let关键字可以使用 `` 包裹参数标签
func addParameter(name: String, `inout`: Bool)
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有