From 2cd154ed2a8b18571f64921d3fad45400ced72d9 Mon Sep 17 00:00:00 2001 From: Spiros Gerokostas Date: Tue, 1 Mar 2016 12:14:50 +0200 Subject: [PATCH] basic scrollview example --- Example-iOS/AppDelegate.swift | 12 ++++++++- Example-iOS/ListViewController.swift | 26 ++++++++++++++++--- .../demos/BasicUIScrollViewController.swift | 18 +++++++++++++ SnapKit.xcodeproj/project.pbxproj | 13 ++++++++++ 4 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 Example-iOS/demos/BasicUIScrollViewController.swift diff --git a/Example-iOS/AppDelegate.swift b/Example-iOS/AppDelegate.swift index 02e1dfa..fa17ea3 100644 --- a/Example-iOS/AppDelegate.swift +++ b/Example-iOS/AppDelegate.swift @@ -15,7 +15,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { - // Override point for customization after application launch. + + self.window = UIWindow(frame: UIScreen.mainScreen().bounds) + + let listViewController:ListViewController = ListViewController() + let navigationController:UINavigationController = UINavigationController(rootViewController: listViewController); + + self.window!.rootViewController = navigationController; + + self.window!.backgroundColor = UIColor.whiteColor() + self.window!.makeKeyAndVisible() + return true } diff --git a/Example-iOS/ListViewController.swift b/Example-iOS/ListViewController.swift index 3160956..e5693cc 100644 --- a/Example-iOS/ListViewController.swift +++ b/Example-iOS/ListViewController.swift @@ -9,16 +9,36 @@ import UIKit import SnapKit -class ListViewController: UIViewController { +class ListViewController: UITableViewController { + let kCellIdentifier = "CellIdentifier" + let demos = ["Basic UIScrollView"] + override func viewDidLoad() { super.viewDidLoad() self.title = "SnapKit iOS Demos" + + self.tableView?.registerClass(UITableViewCell.self, forCellReuseIdentifier: kCellIdentifier) } + override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCellWithIdentifier(kCellIdentifier)! as UITableViewCell + + cell.textLabel?.text = demos[indexPath.row] + + return cell + } - - + override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return demos.count + } + + override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + if indexPath.row == 0 { + let viewController = BasicUIScrollViewController() + navigationController?.pushViewController(viewController, animated: true) + } + } } diff --git a/Example-iOS/demos/BasicUIScrollViewController.swift b/Example-iOS/demos/BasicUIScrollViewController.swift new file mode 100644 index 0000000..91b2532 --- /dev/null +++ b/Example-iOS/demos/BasicUIScrollViewController.swift @@ -0,0 +1,18 @@ +// +// BasicUIScrollViewController.swift +// SnapKit +// +// Created by Spiros Gerokostas on 01/03/16. +// Copyright © 2016 SnapKit Team. All rights reserved. +// + +import UIKit + +class BasicUIScrollViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + view.backgroundColor = UIColor.whiteColor() + } +} diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index d168c8d..0152fc1 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -29,6 +29,7 @@ 56A0DC1C1C859E9A005973AB /* SnapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EEBCC9D819CC627D0083B827 /* SnapKit.framework */; }; 56A0DC1D1C859E9A005973AB /* SnapKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EEBCC9D819CC627D0083B827 /* SnapKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 56A0DC221C859F15005973AB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A0DC211C859F15005973AB /* AppDelegate.swift */; }; + 56A0DC321C85A2C1005973AB /* BasicUIScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A0DC311C85A2C1005973AB /* BasicUIScrollViewController.swift */; }; EE4910981B19A26000A54F1F /* ViewController+SnapKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE4910971B19A26000A54F1F /* ViewController+SnapKit.swift */; }; EE4910991B19A40200A54F1F /* SnapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EEBCC9D819CC627D0083B827 /* SnapKit.framework */; }; EE94F6091AC0F10A008767FF /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE94F6081AC0F10A008767FF /* UIKit.framework */; }; @@ -103,6 +104,7 @@ 56A0DC151C859E30005973AB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 56A0DC171C859E30005973AB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56A0DC211C859F15005973AB /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 56A0DC311C85A2C1005973AB /* BasicUIScrollViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicUIScrollViewController.swift; sourceTree = ""; }; EE4910971B19A26000A54F1F /* ViewController+SnapKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ViewController+SnapKit.swift"; sourceTree = ""; }; EE94F6081AC0F10A008767FF /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; EE94F60A1AC0F10F008767FF /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework; sourceTree = DEVELOPER_DIR; }; @@ -190,6 +192,7 @@ 56A0DC0A1C859E30005973AB /* Example-iOS */ = { isa = PBXGroup; children = ( + 56A0DC301C85A20E005973AB /* demos */, 56A0DC211C859F15005973AB /* AppDelegate.swift */, 56A0DC0D1C859E30005973AB /* ListViewController.swift */, 56A0DC121C859E30005973AB /* Assets.xcassets */, @@ -199,6 +202,14 @@ path = "Example-iOS"; sourceTree = ""; }; + 56A0DC301C85A20E005973AB /* demos */ = { + isa = PBXGroup; + children = ( + 56A0DC311C85A2C1005973AB /* BasicUIScrollViewController.swift */, + ); + path = demos; + sourceTree = ""; + }; DDC9FD8C1981B4DD009612C7 = { isa = PBXGroup; children = ( @@ -572,6 +583,7 @@ buildActionMask = 2147483647; files = ( 56A0DC221C859F15005973AB /* AppDelegate.swift in Sources */, + 56A0DC321C85A2C1005973AB /* BasicUIScrollViewController.swift in Sources */, 56A0DC0E1C859E30005973AB /* ListViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1023,6 +1035,7 @@ 56A0DC191C859E30005973AB /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; DDC9FD901981B4DD009612C7 /* Build configuration list for PBXProject "SnapKit" */ = { isa = XCConfigurationList;