美文网首页
更新项目Swift 4.0-4.2:

更新项目Swift 4.0-4.2:

作者: 玉思盈蝶 | 来源:发表于2018-12-22 16:19 被阅读178次

谁知道我今天经历了什么~~~


屏幕快照 2018-12-22 下午1.09.00.png

Swift 4.0:

NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name:NSNotification.Name.UIKeyboardWillHide, object: nil)

Swift 4.2:

NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name:NSNotification.Name.UIKeyboardWillHide, object: nil)

Swift 4.0:

NotificationCenter.default.addObserver(self, selector: #selector(textFieldTextDidChange(notification:)), name: NSNotification.Name.UITextFieldTextDidChange, object: scoreView.scoreTextField)

Swift 4.2:

NotificationCenter.default.addObserver(self, selector: #selector(textFieldTextDidChange(notification:)), name: UITextField.textDidChangeNotification, object: scoreView.scoreTextField)

Swift 4.0:

let attrs = [NSAttributedStringKey.foregroundColor: UIColor.white,

Swift 4.2:

NSAttributedString.Key.font: UIFont.systemFont(ofSize: 18)]

Swift 4.0:

make.edges.equalTo(self.backGroundView).inset(UIEdgeInsetsMake(30, 30, 30, 30))

Swift 4.2:

make.edges.equalTo(self.backGroundView).inset(UIEdgeInsets(top: 30, left: 30, bottom: 30, right: 30))

Swift 4.0:

override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
}

Swift 4.2:

override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
}

Swift 4.0:

addChildViewController(payBillDetailViewController)

Swift 4.2:

addChild(prePayViewController)

Swift 4.0:

collectionView.registerClassFromClass(type: RedEnvelopeCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader)

Swift 4.2:

collectionView.registerClassFromClass(type: RedEnvelopeCollectionReusableView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader)

Swift 4.0:

button.setBackgroundImage(UIImage(named: "x"), for: UIControlState.normal)

Swift 4.2:

button.setBackgroundImage(UIImage(named: "x"), for: .normal)
override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
       if kind == UICollectionElementKindSectionHeader {
       if kind == UICollectionView.elementKindSectionHeader {
             
             if showType == .image && indexPath.section == 0 {
              let header = collectionView.dequeueReusableCell(kind: UICollectionElementKindSectionHeader, withReuseType: OrderDishOrPotJumpReusableView.self, forIndexPath: indexPath)
                let header = collectionView.dequeueReusableCell(kind: UICollectionView.elementKindSectionHeader, withReuseType: OrderDishOrPotJumpReusableView.self, forIndexPath: indexPath)
                 let name = titleArray[indexPath.section]
                 let big = name.big.categoryNameShow
                 let small = name.small.dishSmallCategoryNameShow

Swift 4.2:

override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
       if kind == UICollectionElementKindSectionHeader {
       if kind == UICollectionView.elementKindSectionHeader {
             
             if showType == .image && indexPath.section == 0 {
              let header = collectionView.dequeueReusableCell(kind: UICollectionElementKindSectionHeader, withReuseType: OrderDishOrPotJumpReusableView.self, forIndexPath: indexPath)
               let header = collectionView.dequeueReusableCell(kind: UICollectionView.elementKindSectionHeader, withReuseType: OrderDishOrPotJumpReusableView.self, forIndexPath: indexPath)
                 let name = titleArray[indexPath.section]
                 let big = name.big.categoryNameShow
                 let small = name.small.dishSmallCategoryNameShow

Swift 4.0:

print(self.childViewControllers.count)

Swift 4.2:

print(self.children.count)

Swift 4.0:

dayPickScrollerView.decelerationRate = 0.5

Swift 4.2:

dayPickScrollerView.decelerationRate = UIScrollView.DecelerationRate(rawValue: 0.5)

13.报错
'UIInterfaceOrientationIsLandscape' has been replaced by property 'UIInterfaceOrientation.isLandscap:

if UIInterfaceOrientation.landscapeLeft.isLandscape {
let tmp = screenWidth
screenWidth = screenHeight
screenHeight = tmp
}

isLandscape是一个属性,需要先有实例对象。

上次看到将就400个错,吓得赶紧用了4.0版本,今天还是鼓起勇气更新了一波,毕竟今年要过完了嘛,嘿嘿,一个不喜欢遗留任务的女孩~~~

相关文章

网友评论

      本文标题:更新项目Swift 4.0-4.2:

      本文链接:https://www.haomeiwen.com/subject/aroikqtx.html