From 8d0965a5b3fa6c73425bcbd36b513e55c35f1bc6 Mon Sep 17 00:00:00 2001 From: Terence Chen Date: Wed, 17 Oct 2018 15:40:49 -0400 Subject: [PATCH] Migrate to Swift 4.2 and add settings for iPhone X, Xs, XR and Xs Max landscape support --- Sources/ASHorizontalScrollView.swift | 55 ++++--- .../project.pbxproj | 150 +++--------------- .../sampleScorllViewInSwift.xcscheme | 2 +- .../ASHorizontalScrollView.swift | 57 ++++--- .../sampleScorllViewInSwift/AppDelegate.swift | 2 +- .../ViewController.swift | 12 +- .../sampleScorllViewInSwiftTests/Info.plist | 24 --- .../sampleScorllViewInSwiftTests.swift | 35 ---- 8 files changed, 94 insertions(+), 243 deletions(-) delete mode 100644 sampleScorllViewInSwift/sampleScorllViewInSwiftTests/Info.plist delete mode 100644 sampleScorllViewInSwift/sampleScorllViewInSwiftTests/sampleScorllViewInSwiftTests.swift diff --git a/Sources/ASHorizontalScrollView.swift b/Sources/ASHorizontalScrollView.swift index 670976c..453b5e1 100644 --- a/Sources/ASHorizontalScrollView.swift +++ b/Sources/ASHorizontalScrollView.swift @@ -1,24 +1,25 @@ /* --------------------------------------------------------- -* ASHorizontalScrollView.swift -* The MIT License (MIT) -* Copyright (C) 2014-2017 WEIWEI CHEN -* --------------------------------------------------------- -* History -* Created by WEIWEI CHEN on 14-6-8. -* Edit by WEIWEI CHEN 14-9-21: fix problems to work on xcode 6.0.1 -* Edit by WEIWEI CHEN 15-12-09: change to adapt Swift 2.1, add comments on functions, remove scale when calculating margin, it seems that the behaviour in iOS 9 change the way of align views -* Edit by WEIWEI CHEN 16-05-17: change C style code to swift 3 format, fix removeItemAtIndex last index crash bug -* Edit by WEIWEI CHEN 16-09-15: Change to adapt Swift 3 with Xcode 8, add support to nib, just change the class on nib file to ASHorizontalScrollView -* Edit by WEIWEI CHEN 16-12-02: When current item scroll to more than specified width, auto scroll to next item (mimic App Store behaviour which is about 1/3); add support to all apple screen sizes, now you can specified different mini margin, mini appear width and left margin for all sorts of screen sizes. -* Edit by WEIWEI CHEN 17-01-24: Introduce new properties to allow set number of items per screen for multiple screen sizes instead of setting minimum margins, as well as new properties to center subviews when items are not wide enough to use whole screen width -* Edit by WEIWEI CHEN 17-03-03: check items size before removing all items -* -* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -* -------------------------------------------------------*/ + * ASHorizontalScrollView.swift + * The MIT License (MIT) + * Copyright (C) 2014-Current WEIWEI CHEN + * --------------------------------------------------------- + * History + * Created by WEIWEI CHEN on 14-6-8. + * Edit by WEIWEI CHEN 14-9-21: fix problems to work on xcode 6.0.1 + * Edit by WEIWEI CHEN 15-12-09: change to adapt Swift 2.1, add comments on functions, remove scale when calculating margin, it seems that the behaviour in iOS 9 change the way of align views + * Edit by WEIWEI CHEN 16-05-17: change C style code to swift 3 format, fix removeItemAtIndex last index crash bug + * Edit by WEIWEI CHEN 16-09-15: Change to adapt Swift 3 with Xcode 8, add support to nib, just change the class on nib file to ASHorizontalScrollView + * Edit by WEIWEI CHEN 16-12-02: When current item scroll to more than specified width, auto scroll to next item (mimic App Store behaviour which is about 1/3); add support to all apple screen sizes, now you can specified different mini margin, mini appear width and left margin for all sorts of screen sizes. + * Edit by WEIWEI CHEN 17-01-24: Introduce new properties to allow set number of items per screen for multiple screen sizes instead of setting minimum margins, as well as new properties to center subviews when items are not wide enough to use whole screen width + * Edit by WEIWEI CHEN 17-03-03: check items size before removing all items + * Edit by WEIWEI CHEN 18-10-17: migrate to Swift 4.2 and add settings for iPhone X, Xs, XR and Xs Max landscape support, thanks to Anton Dryakhlykh help on the migration. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * -------------------------------------------------------*/ import UIKit @@ -81,7 +82,7 @@ open class ASHorizontalScrollView: UIScrollView, UIScrollViewDelegate { } } } - + /// whether to arrange items by frame or by number of items, if set by frame, all margin would be calculated by frame size, otherwise, calculated by number of items per screen /// - check `numberOfItemsPerScreen` for arranged by number type @@ -143,6 +144,14 @@ open class ASHorizontalScrollView: UIScrollView, UIScrollViewDelegate { if let setting = marginSettings_736 { return setting } + case 812: + if let setting = marginSettings_812 { + return setting + } + case 896: + if let setting = marginSettings_896 { + return setting + } case 1366: if let setting = marginSettings_1366 { return setting @@ -174,6 +183,10 @@ open class ASHorizontalScrollView: UIScrollView, UIScrollViewDelegate { public var marginSettings_667:MarginSettings? /// for iPhone 6 plus and 6s plus in landscape public var marginSettings_736:MarginSettings? + /// for iPhone X and Xs in landscape + public var marginSettings_812:MarginSettings? + /// for iPhone Xs Max and XR in landscape + public var marginSettings_896:MarginSettings? /// for ipad and ipad pro 9.7 in landscape and ipad pro 12.9 portrait public var marginSettings_1024:MarginSettings? /// for ipad pro 12.9 in landscape diff --git a/sampleScorllViewInSwift/sampleScorllViewInSwift.xcodeproj/project.pbxproj b/sampleScorllViewInSwift/sampleScorllViewInSwift.xcodeproj/project.pbxproj index 395c0a8..77ba267 100644 --- a/sampleScorllViewInSwift/sampleScorllViewInSwift.xcodeproj/project.pbxproj +++ b/sampleScorllViewInSwift/sampleScorllViewInSwift.xcodeproj/project.pbxproj @@ -11,20 +11,9 @@ 7465DEDD19453DB100AA9A5D /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7465DEDC19453DB100AA9A5D /* ViewController.swift */; }; 7465DEE019453DB100AA9A5D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7465DEDE19453DB100AA9A5D /* Main.storyboard */; }; 7465DEE219453DB100AA9A5D /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7465DEE119453DB100AA9A5D /* Images.xcassets */; }; - 7465DEEE19453DB100AA9A5D /* sampleScorllViewInSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7465DEED19453DB100AA9A5D /* sampleScorllViewInSwiftTests.swift */; }; 7465DEF819453E5800AA9A5D /* ASHorizontalScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7465DEF719453E5800AA9A5D /* ASHorizontalScrollView.swift */; }; /* End PBXBuildFile section */ -/* Begin PBXContainerItemProxy section */ - 7465DEE819453DB100AA9A5D /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 7465DECD19453DB100AA9A5D /* Project object */; - proxyType = 1; - remoteGlobalIDString = 7465DED419453DB100AA9A5D; - remoteInfo = sampleScorllViewInSwift; - }; -/* End PBXContainerItemProxy section */ - /* Begin PBXFileReference section */ 7465DED519453DB100AA9A5D /* sampleScorllViewInSwift.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = sampleScorllViewInSwift.app; sourceTree = BUILT_PRODUCTS_DIR; }; 7465DED919453DB100AA9A5D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -32,9 +21,6 @@ 7465DEDC19453DB100AA9A5D /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 7465DEDF19453DB100AA9A5D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 7465DEE119453DB100AA9A5D /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - 7465DEE719453DB100AA9A5D /* sampleScorllViewInSwiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = sampleScorllViewInSwiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 7465DEEC19453DB100AA9A5D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 7465DEED19453DB100AA9A5D /* sampleScorllViewInSwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = sampleScorllViewInSwiftTests.swift; sourceTree = ""; }; 7465DEF719453E5800AA9A5D /* ASHorizontalScrollView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ASHorizontalScrollView.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -46,13 +32,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 7465DEE419453DB100AA9A5D /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -60,7 +39,6 @@ isa = PBXGroup; children = ( 7465DED719453DB100AA9A5D /* sampleScorllViewInSwift */, - 7465DEEA19453DB100AA9A5D /* sampleScorllViewInSwiftTests */, 7465DED619453DB100AA9A5D /* Products */, ); sourceTree = ""; @@ -69,7 +47,6 @@ isa = PBXGroup; children = ( 7465DED519453DB100AA9A5D /* sampleScorllViewInSwift.app */, - 7465DEE719453DB100AA9A5D /* sampleScorllViewInSwiftTests.xctest */, ); name = Products; sourceTree = ""; @@ -95,23 +72,6 @@ name = "Supporting Files"; sourceTree = ""; }; - 7465DEEA19453DB100AA9A5D /* sampleScorllViewInSwiftTests */ = { - isa = PBXGroup; - children = ( - 7465DEED19453DB100AA9A5D /* sampleScorllViewInSwiftTests.swift */, - 7465DEEB19453DB100AA9A5D /* Supporting Files */, - ); - path = sampleScorllViewInSwiftTests; - sourceTree = ""; - }; - 7465DEEB19453DB100AA9A5D /* Supporting Files */ = { - isa = PBXGroup; - children = ( - 7465DEEC19453DB100AA9A5D /* Info.plist */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -132,24 +92,6 @@ productReference = 7465DED519453DB100AA9A5D /* sampleScorllViewInSwift.app */; productType = "com.apple.product-type.application"; }; - 7465DEE619453DB100AA9A5D /* sampleScorllViewInSwiftTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 7465DEF419453DB100AA9A5D /* Build configuration list for PBXNativeTarget "sampleScorllViewInSwiftTests" */; - buildPhases = ( - 7465DEE319453DB100AA9A5D /* Sources */, - 7465DEE419453DB100AA9A5D /* Frameworks */, - 7465DEE519453DB100AA9A5D /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 7465DEE919453DB100AA9A5D /* PBXTargetDependency */, - ); - name = sampleScorllViewInSwiftTests; - productName = sampleScorllViewInSwiftTests; - productReference = 7465DEE719453DB100AA9A5D /* sampleScorllViewInSwiftTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -158,18 +100,13 @@ attributes = { LastSwiftMigration = 0710; LastSwiftUpdateCheck = 0710; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 1000; ORGANIZATIONNAME = Zuse; TargetAttributes = { 7465DED419453DB100AA9A5D = { CreatedOnToolsVersion = 6.0; LastSwiftMigration = 0810; }; - 7465DEE619453DB100AA9A5D = { - CreatedOnToolsVersion = 6.0; - LastSwiftMigration = 0810; - TestTargetID = 7465DED419453DB100AA9A5D; - }; }; }; buildConfigurationList = 7465DED019453DB100AA9A5D /* Build configuration list for PBXProject "sampleScorllViewInSwift" */; @@ -186,7 +123,6 @@ projectRoot = ""; targets = ( 7465DED419453DB100AA9A5D /* sampleScorllViewInSwift */, - 7465DEE619453DB100AA9A5D /* sampleScorllViewInSwiftTests */, ); }; /* End PBXProject section */ @@ -201,13 +137,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 7465DEE519453DB100AA9A5D /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -221,24 +150,8 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 7465DEE319453DB100AA9A5D /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 7465DEEE19453DB100AA9A5D /* sampleScorllViewInSwiftTests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXTargetDependency section */ - 7465DEE919453DB100AA9A5D /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 7465DED419453DB100AA9A5D /* sampleScorllViewInSwift */; - targetProxy = 7465DEE819453DB100AA9A5D /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - /* Begin PBXVariantGroup section */ 7465DEDE19453DB100AA9A5D /* Main.storyboard */ = { isa = PBXVariantGroup; @@ -259,14 +172,22 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -307,14 +228,22 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -349,7 +278,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "Zuse.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0.1; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -362,39 +291,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "Zuse.${PRODUCT_NAME:rfc1034identifier}"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0.1; - }; - name = Release; - }; - 7465DEF519453DB100AA9A5D /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/sampleScorllViewInSwift.app/sampleScorllViewInSwift"; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - INFOPLIST_FILE = sampleScorllViewInSwiftTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - METAL_ENABLE_DEBUG_INFO = YES; - PRODUCT_BUNDLE_IDENTIFIER = "Zuse.${PRODUCT_NAME:rfc1034identifier}"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0.1; - TEST_HOST = "$(BUNDLE_LOADER)"; - }; - name = Debug; - }; - 7465DEF619453DB100AA9A5D /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/sampleScorllViewInSwift.app/sampleScorllViewInSwift"; - INFOPLIST_FILE = sampleScorllViewInSwiftTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - METAL_ENABLE_DEBUG_INFO = NO; - PRODUCT_BUNDLE_IDENTIFIER = "Zuse.${PRODUCT_NAME:rfc1034identifier}"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0.1; - TEST_HOST = "$(BUNDLE_LOADER)"; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -419,15 +316,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 7465DEF419453DB100AA9A5D /* Build configuration list for PBXNativeTarget "sampleScorllViewInSwiftTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 7465DEF519453DB100AA9A5D /* Debug */, - 7465DEF619453DB100AA9A5D /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; /* End XCConfigurationList section */ }; rootObject = 7465DECD19453DB100AA9A5D /* Project object */; diff --git a/sampleScorllViewInSwift/sampleScorllViewInSwift.xcodeproj/xcuserdata/terencechen.xcuserdatad/xcschemes/sampleScorllViewInSwift.xcscheme b/sampleScorllViewInSwift/sampleScorllViewInSwift.xcodeproj/xcuserdata/terencechen.xcuserdatad/xcschemes/sampleScorllViewInSwift.xcscheme index eaf486c..6ff8204 100644 --- a/sampleScorllViewInSwift/sampleScorllViewInSwift.xcodeproj/xcuserdata/terencechen.xcuserdatad/xcschemes/sampleScorllViewInSwift.xcscheme +++ b/sampleScorllViewInSwift/sampleScorllViewInSwift.xcodeproj/xcuserdata/terencechen.xcuserdatad/xcschemes/sampleScorllViewInSwift.xcscheme @@ -1,6 +1,6 @@ Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { return true } diff --git a/sampleScorllViewInSwift/sampleScorllViewInSwift/ViewController.swift b/sampleScorllViewInSwift/sampleScorllViewInSwift/ViewController.swift index 68da7ce..af4be45 100644 --- a/sampleScorllViewInSwift/sampleScorllViewInSwift/ViewController.swift +++ b/sampleScorllViewInSwift/sampleScorllViewInSwift/ViewController.swift @@ -34,7 +34,7 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour self.sampleTableView = UITableView(frame:CGRect(x: 0,y: 0,width: self.view.frame.size.width, height: self.view.frame.size.height), style:.grouped) sampleTableView.dataSource = self sampleTableView.delegate = self - sampleTableView.autoresizingMask = [UIViewAutoresizing.flexibleWidth, UIViewAutoresizing.flexibleHeight] + sampleTableView.autoresizingMask = [UIView.AutoresizingMask.flexibleWidth, UIView.AutoresizingMask.flexibleHeight] self.view.addSubview(sampleTableView) } @@ -56,7 +56,7 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour var cell = tableView.dequeueReusableCell(withIdentifier: indentifier) if (cell == nil) { - cell = UITableViewCell(style: UITableViewCellStyle.subtitle, reuseIdentifier: indentifier) + cell = UITableViewCell(style: UITableViewCell.CellStyle.subtitle, reuseIdentifier: indentifier) cell?.selectionStyle = .none let horizontalScrollView:ASHorizontalScrollView = ASHorizontalScrollView(frame:CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: kCellHeight)) //for iPhone 5s and lower versions in portrait @@ -114,10 +114,10 @@ class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSour } cell?.contentView.addSubview(horizontalScrollView) horizontalScrollView.translatesAutoresizingMaskIntoConstraints = false - cell?.contentView.addConstraint(NSLayoutConstraint(item: horizontalScrollView, attribute: NSLayoutAttribute.left, relatedBy: NSLayoutRelation.equal, toItem: cell!.contentView, attribute: NSLayoutAttribute.left, multiplier: 1, constant: 0)) - cell?.contentView.addConstraint(NSLayoutConstraint(item: horizontalScrollView, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: cell!.contentView, attribute: NSLayoutAttribute.top, multiplier: 1, constant: 0)) - cell?.contentView.addConstraint(NSLayoutConstraint(item: horizontalScrollView, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: kCellHeight)) - cell?.contentView.addConstraint(NSLayoutConstraint(item: horizontalScrollView, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.equal, toItem: cell!.contentView, attribute: NSLayoutAttribute.width, multiplier: 1, constant: 0)) + cell?.contentView.addConstraint(NSLayoutConstraint(item: horizontalScrollView, attribute: NSLayoutConstraint.Attribute.left, relatedBy: NSLayoutConstraint.Relation.equal, toItem: cell!.contentView, attribute: NSLayoutConstraint.Attribute.left, multiplier: 1, constant: 0)) + cell?.contentView.addConstraint(NSLayoutConstraint(item: horizontalScrollView, attribute: NSLayoutConstraint.Attribute.top, relatedBy: NSLayoutConstraint.Relation.equal, toItem: cell!.contentView, attribute: NSLayoutConstraint.Attribute.top, multiplier: 1, constant: 0)) + cell?.contentView.addConstraint(NSLayoutConstraint(item: horizontalScrollView, attribute: NSLayoutConstraint.Attribute.height, relatedBy: NSLayoutConstraint.Relation.equal, toItem: nil, attribute: NSLayoutConstraint.Attribute.notAnAttribute, multiplier: 1, constant: kCellHeight)) + cell?.contentView.addConstraint(NSLayoutConstraint(item: horizontalScrollView, attribute: NSLayoutConstraint.Attribute.width, relatedBy: NSLayoutConstraint.Relation.equal, toItem: cell!.contentView, attribute: NSLayoutConstraint.Attribute.width, multiplier: 1, constant: 0)) } else if let horizontalScrollView = cell?.contentView.subviews.first(where: { (view) -> Bool in return view is ASHorizontalScrollView diff --git a/sampleScorllViewInSwift/sampleScorllViewInSwiftTests/Info.plist b/sampleScorllViewInSwift/sampleScorllViewInSwiftTests/Info.plist deleted file mode 100644 index 6d32c15..0000000 --- a/sampleScorllViewInSwift/sampleScorllViewInSwiftTests/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/sampleScorllViewInSwift/sampleScorllViewInSwiftTests/sampleScorllViewInSwiftTests.swift b/sampleScorllViewInSwift/sampleScorllViewInSwiftTests/sampleScorllViewInSwiftTests.swift deleted file mode 100644 index e816f88..0000000 --- a/sampleScorllViewInSwift/sampleScorllViewInSwiftTests/sampleScorllViewInSwiftTests.swift +++ /dev/null @@ -1,35 +0,0 @@ -// -// sampleScorllViewInSwiftTests.swift -// sampleScorllViewInSwiftTests -// -// Created by Vivien on 14-6-8. -// Copyright (c) 2014年 Zuse. All rights reserved. -// - -import XCTest - -class sampleScorllViewInSwiftTests: XCTestCase { - - override func setUp() { - super.setUp() - // Put setup code here. This method is called before the invocation of each test method in the class. - } - - override func tearDown() { - // Put teardown code here. This method is called after the invocation of each test method in the class. - super.tearDown() - } - - func testExample() { - // This is an example of a functional test case. - XCTAssert(true, "Pass") - } - - func testPerformanceExample() { - // This is an example of a performance test case. - self.measure() { - // Put the code you want to measure the time of here. - } - } - -}