├── .gitignore ├── LICENSE.md ├── PBDataTable.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── PBDataTable ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── ascending.imageset │ │ ├── Contents.json │ │ ├── ic_ascending_selected.png │ │ └── ic_ascending_selected@2x.png │ ├── descending.imageset │ │ ├── Contents.json │ │ ├── ic_descending.png │ │ └── ic_descending@2x.png │ └── none.imageset │ │ ├── Contents.json │ │ ├── ic_ascending_default.png │ │ └── ic_ascending_default@2x.png ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Classes │ ├── PBDataTableView.swift │ ├── PBDataTableView.xib │ ├── PBDataTableViewCell.swift │ └── PBDataTableViewCell.xib ├── Info.plist └── ViewController.swift ├── README.md └── iPAD_DataTableView.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Praveen B 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PBDataTable.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | ACF956C01D0AC3F800B8BC24 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACF956BF1D0AC3F800B8BC24 /* AppDelegate.swift */; }; 11 | ACF956C21D0AC3F800B8BC24 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACF956C11D0AC3F800B8BC24 /* ViewController.swift */; }; 12 | ACF956C51D0AC3F800B8BC24 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ACF956C31D0AC3F800B8BC24 /* Main.storyboard */; }; 13 | ACF956C71D0AC3F800B8BC24 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = ACF956C61D0AC3F800B8BC24 /* Assets.xcassets */; }; 14 | ACF956CA1D0AC3F800B8BC24 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = ACF956C81D0AC3F800B8BC24 /* LaunchScreen.storyboard */; }; 15 | ACF956D31D0AC5D100B8BC24 /* PBDataTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACF956D21D0AC5D100B8BC24 /* PBDataTableView.swift */; }; 16 | ACF956D51D0AC5ED00B8BC24 /* PBDataTableView.xib in Resources */ = {isa = PBXBuildFile; fileRef = ACF956D41D0AC5EC00B8BC24 /* PBDataTableView.xib */; }; 17 | ACF956DA1D0ACC8000B8BC24 /* PBDataTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACF956D81D0ACC8000B8BC24 /* PBDataTableViewCell.swift */; }; 18 | ACF956DB1D0ACC8000B8BC24 /* PBDataTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = ACF956D91D0ACC8000B8BC24 /* PBDataTableViewCell.xib */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | ACF956BC1D0AC3F800B8BC24 /* PBDataTable.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PBDataTable.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | ACF956BF1D0AC3F800B8BC24 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 24 | ACF956C11D0AC3F800B8BC24 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 25 | ACF956C41D0AC3F800B8BC24 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | ACF956C61D0AC3F800B8BC24 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 27 | ACF956C91D0AC3F800B8BC24 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 28 | ACF956CB1D0AC3F800B8BC24 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | ACF956D21D0AC5D100B8BC24 /* PBDataTableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PBDataTableView.swift; sourceTree = ""; }; 30 | ACF956D41D0AC5EC00B8BC24 /* PBDataTableView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PBDataTableView.xib; sourceTree = ""; }; 31 | ACF956D81D0ACC8000B8BC24 /* PBDataTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PBDataTableViewCell.swift; sourceTree = ""; }; 32 | ACF956D91D0ACC8000B8BC24 /* PBDataTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PBDataTableViewCell.xib; sourceTree = ""; }; 33 | /* End PBXFileReference section */ 34 | 35 | /* Begin PBXFrameworksBuildPhase section */ 36 | ACF956B91D0AC3F800B8BC24 /* Frameworks */ = { 37 | isa = PBXFrameworksBuildPhase; 38 | buildActionMask = 2147483647; 39 | files = ( 40 | ); 41 | runOnlyForDeploymentPostprocessing = 0; 42 | }; 43 | /* End PBXFrameworksBuildPhase section */ 44 | 45 | /* Begin PBXGroup section */ 46 | ACF956B31D0AC3F800B8BC24 = { 47 | isa = PBXGroup; 48 | children = ( 49 | ACF956BE1D0AC3F800B8BC24 /* PBDataTable */, 50 | ACF956BD1D0AC3F800B8BC24 /* Products */, 51 | ); 52 | sourceTree = ""; 53 | }; 54 | ACF956BD1D0AC3F800B8BC24 /* Products */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | ACF956BC1D0AC3F800B8BC24 /* PBDataTable.app */, 58 | ); 59 | name = Products; 60 | sourceTree = ""; 61 | }; 62 | ACF956BE1D0AC3F800B8BC24 /* PBDataTable */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | ACF956D11D0AC55200B8BC24 /* Classes */, 66 | ACF956BF1D0AC3F800B8BC24 /* AppDelegate.swift */, 67 | ACF956C11D0AC3F800B8BC24 /* ViewController.swift */, 68 | ACF956C31D0AC3F800B8BC24 /* Main.storyboard */, 69 | ACF956C61D0AC3F800B8BC24 /* Assets.xcassets */, 70 | ACF956C81D0AC3F800B8BC24 /* LaunchScreen.storyboard */, 71 | ACF956CB1D0AC3F800B8BC24 /* Info.plist */, 72 | ); 73 | path = PBDataTable; 74 | sourceTree = ""; 75 | }; 76 | ACF956D11D0AC55200B8BC24 /* Classes */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | ACF956D21D0AC5D100B8BC24 /* PBDataTableView.swift */, 80 | ACF956D41D0AC5EC00B8BC24 /* PBDataTableView.xib */, 81 | ACF956D81D0ACC8000B8BC24 /* PBDataTableViewCell.swift */, 82 | ACF956D91D0ACC8000B8BC24 /* PBDataTableViewCell.xib */, 83 | ); 84 | path = Classes; 85 | sourceTree = ""; 86 | }; 87 | /* End PBXGroup section */ 88 | 89 | /* Begin PBXNativeTarget section */ 90 | ACF956BB1D0AC3F800B8BC24 /* PBDataTable */ = { 91 | isa = PBXNativeTarget; 92 | buildConfigurationList = ACF956CE1D0AC3F800B8BC24 /* Build configuration list for PBXNativeTarget "PBDataTable" */; 93 | buildPhases = ( 94 | ACF956B81D0AC3F800B8BC24 /* Sources */, 95 | ACF956B91D0AC3F800B8BC24 /* Frameworks */, 96 | ACF956BA1D0AC3F800B8BC24 /* Resources */, 97 | ); 98 | buildRules = ( 99 | ); 100 | dependencies = ( 101 | ); 102 | name = PBDataTable; 103 | productName = PBDataTable; 104 | productReference = ACF956BC1D0AC3F800B8BC24 /* PBDataTable.app */; 105 | productType = "com.apple.product-type.application"; 106 | }; 107 | /* End PBXNativeTarget section */ 108 | 109 | /* Begin PBXProject section */ 110 | ACF956B41D0AC3F800B8BC24 /* Project object */ = { 111 | isa = PBXProject; 112 | attributes = { 113 | LastSwiftUpdateCheck = 0730; 114 | LastUpgradeCheck = 0730; 115 | ORGANIZATIONNAME = Praveen; 116 | TargetAttributes = { 117 | ACF956BB1D0AC3F800B8BC24 = { 118 | CreatedOnToolsVersion = 7.3.1; 119 | LastSwiftMigration = 0800; 120 | }; 121 | }; 122 | }; 123 | buildConfigurationList = ACF956B71D0AC3F800B8BC24 /* Build configuration list for PBXProject "PBDataTable" */; 124 | compatibilityVersion = "Xcode 3.2"; 125 | developmentRegion = English; 126 | hasScannedForEncodings = 0; 127 | knownRegions = ( 128 | en, 129 | Base, 130 | ); 131 | mainGroup = ACF956B31D0AC3F800B8BC24; 132 | productRefGroup = ACF956BD1D0AC3F800B8BC24 /* Products */; 133 | projectDirPath = ""; 134 | projectRoot = ""; 135 | targets = ( 136 | ACF956BB1D0AC3F800B8BC24 /* PBDataTable */, 137 | ); 138 | }; 139 | /* End PBXProject section */ 140 | 141 | /* Begin PBXResourcesBuildPhase section */ 142 | ACF956BA1D0AC3F800B8BC24 /* Resources */ = { 143 | isa = PBXResourcesBuildPhase; 144 | buildActionMask = 2147483647; 145 | files = ( 146 | ACF956DB1D0ACC8000B8BC24 /* PBDataTableViewCell.xib in Resources */, 147 | ACF956CA1D0AC3F800B8BC24 /* LaunchScreen.storyboard in Resources */, 148 | ACF956C71D0AC3F800B8BC24 /* Assets.xcassets in Resources */, 149 | ACF956C51D0AC3F800B8BC24 /* Main.storyboard in Resources */, 150 | ACF956D51D0AC5ED00B8BC24 /* PBDataTableView.xib in Resources */, 151 | ); 152 | runOnlyForDeploymentPostprocessing = 0; 153 | }; 154 | /* End PBXResourcesBuildPhase section */ 155 | 156 | /* Begin PBXSourcesBuildPhase section */ 157 | ACF956B81D0AC3F800B8BC24 /* Sources */ = { 158 | isa = PBXSourcesBuildPhase; 159 | buildActionMask = 2147483647; 160 | files = ( 161 | ACF956D31D0AC5D100B8BC24 /* PBDataTableView.swift in Sources */, 162 | ACF956C21D0AC3F800B8BC24 /* ViewController.swift in Sources */, 163 | ACF956C01D0AC3F800B8BC24 /* AppDelegate.swift in Sources */, 164 | ACF956DA1D0ACC8000B8BC24 /* PBDataTableViewCell.swift in Sources */, 165 | ); 166 | runOnlyForDeploymentPostprocessing = 0; 167 | }; 168 | /* End PBXSourcesBuildPhase section */ 169 | 170 | /* Begin PBXVariantGroup section */ 171 | ACF956C31D0AC3F800B8BC24 /* Main.storyboard */ = { 172 | isa = PBXVariantGroup; 173 | children = ( 174 | ACF956C41D0AC3F800B8BC24 /* Base */, 175 | ); 176 | name = Main.storyboard; 177 | sourceTree = ""; 178 | }; 179 | ACF956C81D0AC3F800B8BC24 /* LaunchScreen.storyboard */ = { 180 | isa = PBXVariantGroup; 181 | children = ( 182 | ACF956C91D0AC3F800B8BC24 /* Base */, 183 | ); 184 | name = LaunchScreen.storyboard; 185 | sourceTree = ""; 186 | }; 187 | /* End PBXVariantGroup section */ 188 | 189 | /* Begin XCBuildConfiguration section */ 190 | ACF956CC1D0AC3F800B8BC24 /* Debug */ = { 191 | isa = XCBuildConfiguration; 192 | buildSettings = { 193 | ALWAYS_SEARCH_USER_PATHS = NO; 194 | CLANG_ANALYZER_NONNULL = YES; 195 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 196 | CLANG_CXX_LIBRARY = "libc++"; 197 | CLANG_ENABLE_MODULES = YES; 198 | CLANG_ENABLE_OBJC_ARC = YES; 199 | CLANG_WARN_BOOL_CONVERSION = YES; 200 | CLANG_WARN_CONSTANT_CONVERSION = YES; 201 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 202 | CLANG_WARN_EMPTY_BODY = YES; 203 | CLANG_WARN_ENUM_CONVERSION = YES; 204 | CLANG_WARN_INT_CONVERSION = YES; 205 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 206 | CLANG_WARN_UNREACHABLE_CODE = YES; 207 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 208 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 209 | COPY_PHASE_STRIP = NO; 210 | DEBUG_INFORMATION_FORMAT = dwarf; 211 | ENABLE_STRICT_OBJC_MSGSEND = YES; 212 | ENABLE_TESTABILITY = YES; 213 | GCC_C_LANGUAGE_STANDARD = gnu99; 214 | GCC_DYNAMIC_NO_PIC = NO; 215 | GCC_NO_COMMON_BLOCKS = YES; 216 | GCC_OPTIMIZATION_LEVEL = 0; 217 | GCC_PREPROCESSOR_DEFINITIONS = ( 218 | "DEBUG=1", 219 | "$(inherited)", 220 | ); 221 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 222 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 223 | GCC_WARN_UNDECLARED_SELECTOR = YES; 224 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 225 | GCC_WARN_UNUSED_FUNCTION = YES; 226 | GCC_WARN_UNUSED_VARIABLE = YES; 227 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 228 | MTL_ENABLE_DEBUG_INFO = YES; 229 | ONLY_ACTIVE_ARCH = YES; 230 | SDKROOT = iphoneos; 231 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 232 | TARGETED_DEVICE_FAMILY = "1,2"; 233 | }; 234 | name = Debug; 235 | }; 236 | ACF956CD1D0AC3F800B8BC24 /* Release */ = { 237 | isa = XCBuildConfiguration; 238 | buildSettings = { 239 | ALWAYS_SEARCH_USER_PATHS = NO; 240 | CLANG_ANALYZER_NONNULL = YES; 241 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 242 | CLANG_CXX_LIBRARY = "libc++"; 243 | CLANG_ENABLE_MODULES = YES; 244 | CLANG_ENABLE_OBJC_ARC = YES; 245 | CLANG_WARN_BOOL_CONVERSION = YES; 246 | CLANG_WARN_CONSTANT_CONVERSION = YES; 247 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 248 | CLANG_WARN_EMPTY_BODY = YES; 249 | CLANG_WARN_ENUM_CONVERSION = YES; 250 | CLANG_WARN_INT_CONVERSION = YES; 251 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 252 | CLANG_WARN_UNREACHABLE_CODE = YES; 253 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 254 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 255 | COPY_PHASE_STRIP = NO; 256 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 257 | ENABLE_NS_ASSERTIONS = NO; 258 | ENABLE_STRICT_OBJC_MSGSEND = YES; 259 | GCC_C_LANGUAGE_STANDARD = gnu99; 260 | GCC_NO_COMMON_BLOCKS = YES; 261 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 262 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 263 | GCC_WARN_UNDECLARED_SELECTOR = YES; 264 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 265 | GCC_WARN_UNUSED_FUNCTION = YES; 266 | GCC_WARN_UNUSED_VARIABLE = YES; 267 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 268 | MTL_ENABLE_DEBUG_INFO = NO; 269 | SDKROOT = iphoneos; 270 | TARGETED_DEVICE_FAMILY = "1,2"; 271 | VALIDATE_PRODUCT = YES; 272 | }; 273 | name = Release; 274 | }; 275 | ACF956CF1D0AC3F800B8BC24 /* Debug */ = { 276 | isa = XCBuildConfiguration; 277 | buildSettings = { 278 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 279 | INFOPLIST_FILE = PBDataTable/Info.plist; 280 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 281 | PRODUCT_BUNDLE_IDENTIFIER = DataTable.PBDataTable; 282 | PRODUCT_NAME = "$(TARGET_NAME)"; 283 | SWIFT_VERSION = 3.0; 284 | }; 285 | name = Debug; 286 | }; 287 | ACF956D01D0AC3F800B8BC24 /* Release */ = { 288 | isa = XCBuildConfiguration; 289 | buildSettings = { 290 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 291 | INFOPLIST_FILE = PBDataTable/Info.plist; 292 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 293 | PRODUCT_BUNDLE_IDENTIFIER = DataTable.PBDataTable; 294 | PRODUCT_NAME = "$(TARGET_NAME)"; 295 | SWIFT_VERSION = 3.0; 296 | }; 297 | name = Release; 298 | }; 299 | /* End XCBuildConfiguration section */ 300 | 301 | /* Begin XCConfigurationList section */ 302 | ACF956B71D0AC3F800B8BC24 /* Build configuration list for PBXProject "PBDataTable" */ = { 303 | isa = XCConfigurationList; 304 | buildConfigurations = ( 305 | ACF956CC1D0AC3F800B8BC24 /* Debug */, 306 | ACF956CD1D0AC3F800B8BC24 /* Release */, 307 | ); 308 | defaultConfigurationIsVisible = 0; 309 | defaultConfigurationName = Release; 310 | }; 311 | ACF956CE1D0AC3F800B8BC24 /* Build configuration list for PBXNativeTarget "PBDataTable" */ = { 312 | isa = XCConfigurationList; 313 | buildConfigurations = ( 314 | ACF956CF1D0AC3F800B8BC24 /* Debug */, 315 | ACF956D01D0AC3F800B8BC24 /* Release */, 316 | ); 317 | defaultConfigurationIsVisible = 0; 318 | defaultConfigurationName = Release; 319 | }; 320 | /* End XCConfigurationList section */ 321 | }; 322 | rootObject = ACF956B41D0AC3F800B8BC24 /* Project object */; 323 | } 324 | -------------------------------------------------------------------------------- /PBDataTable.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PBDataTable/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // PBDataTable 4 | // 5 | // Created by praveen b on 6/10/16. 6 | // Copyright © 2016 Praveen. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | var ApplicationDelegate = UIApplication.shared.delegate as! AppDelegate 12 | 13 | @UIApplicationMain 14 | class AppDelegate: UIResponder, UIApplicationDelegate { 15 | 16 | var window: UIWindow? 17 | var numberOfColumns: Int! 18 | var cellLastColumnButtonEnable: Bool = false 19 | 20 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 21 | // Override point for customization after application launch. 22 | return true 23 | } 24 | 25 | func applicationWillResignActive(_ application: UIApplication) { 26 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 27 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 28 | } 29 | 30 | func applicationDidEnterBackground(_ application: UIApplication) { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | func applicationWillEnterForeground(_ application: UIApplication) { 36 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 37 | } 38 | 39 | func applicationDidBecomeActive(_ application: UIApplication) { 40 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 41 | } 42 | 43 | func applicationWillTerminate(_ application: UIApplication) { 44 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 45 | } 46 | 47 | 48 | } 49 | 50 | -------------------------------------------------------------------------------- /PBDataTable/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /PBDataTable/Assets.xcassets/ascending.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "ic_ascending_selected.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "ic_ascending_selected@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /PBDataTable/Assets.xcassets/ascending.imageset/ic_ascending_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/praveenb-ios/PBDataTableView/a992e74cb071d4d81f1d167dfaf1e804e2ac8a92/PBDataTable/Assets.xcassets/ascending.imageset/ic_ascending_selected.png -------------------------------------------------------------------------------- /PBDataTable/Assets.xcassets/ascending.imageset/ic_ascending_selected@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/praveenb-ios/PBDataTableView/a992e74cb071d4d81f1d167dfaf1e804e2ac8a92/PBDataTable/Assets.xcassets/ascending.imageset/ic_ascending_selected@2x.png -------------------------------------------------------------------------------- /PBDataTable/Assets.xcassets/descending.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "ic_descending.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "ic_descending@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /PBDataTable/Assets.xcassets/descending.imageset/ic_descending.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/praveenb-ios/PBDataTableView/a992e74cb071d4d81f1d167dfaf1e804e2ac8a92/PBDataTable/Assets.xcassets/descending.imageset/ic_descending.png -------------------------------------------------------------------------------- /PBDataTable/Assets.xcassets/descending.imageset/ic_descending@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/praveenb-ios/PBDataTableView/a992e74cb071d4d81f1d167dfaf1e804e2ac8a92/PBDataTable/Assets.xcassets/descending.imageset/ic_descending@2x.png -------------------------------------------------------------------------------- /PBDataTable/Assets.xcassets/none.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "ic_ascending_default.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "ic_ascending_default@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /PBDataTable/Assets.xcassets/none.imageset/ic_ascending_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/praveenb-ios/PBDataTableView/a992e74cb071d4d81f1d167dfaf1e804e2ac8a92/PBDataTable/Assets.xcassets/none.imageset/ic_ascending_default.png -------------------------------------------------------------------------------- /PBDataTable/Assets.xcassets/none.imageset/ic_ascending_default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/praveenb-ios/PBDataTableView/a992e74cb071d4d81f1d167dfaf1e804e2ac8a92/PBDataTable/Assets.xcassets/none.imageset/ic_ascending_default@2x.png -------------------------------------------------------------------------------- /PBDataTable/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /PBDataTable/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /PBDataTable/Classes/PBDataTableView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PBDataTableView.swift 3 | // PBDataTable 4 | // 5 | // Created by praveen b on 6/10/16. 6 | // Copyright © 2016 Praveen. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | protocol PBDataTableViewDelegate: class { 12 | func tableViewDidSelectedRow(_ indexPath: IndexPath) 13 | func tableViewCellEditButtonTapped(_ indexPath: IndexPath) 14 | } 15 | 16 | class PBDataTableView: UIView { 17 | 18 | @IBOutlet var searchBarHeightConstraint: NSLayoutConstraint! 19 | @IBOutlet var searchBarTrailingConstraint: NSLayoutConstraint! 20 | @IBOutlet var headerVwTrailingConstraint: NSLayoutConstraint! 21 | @IBOutlet var tableVwTrailingConstraint: NSLayoutConstraint! 22 | @IBOutlet var scrollSuperViewTrailingConstraint: NSLayoutConstraint! 23 | 24 | @IBOutlet var bgScrollView: UIScrollView! 25 | @IBOutlet var searchBar: UISearchBar! 26 | @IBOutlet var tableHeaderView: UIView! 27 | @IBOutlet var dataTableView: UITableView! 28 | @IBOutlet var noRecordLbl: UILabel! 29 | 30 | var filteredDataTableArray: NSMutableArray = NSMutableArray() 31 | var dataTableArray: NSMutableArray = NSMutableArray() 32 | var columnDataArray: NSMutableArray = NSMutableArray() 33 | 34 | var columnWidth: CGFloat = 80 35 | var totalColumnWidth: CGFloat = 0 36 | 37 | var enableSorting: Bool = true 38 | var enableCellOuterBorder: Bool = true 39 | var enableCellInnerBorder: Bool = true 40 | var enableSearchBar: Bool = true 41 | 42 | var shouldShowSearchResults = false 43 | 44 | var searchBarBackgroundColor: UIColor = UIColor(red: 246/255, green: 139/255, blue: 31/255, alpha: 1) 45 | var searchBarTxtFldFont: UIFont = UIFont(name: "Helvetica", size: 15)! 46 | var searchBarTxtFldTxtColor: UIColor = UIColor(red: 64/255, green: 64/255, blue: 64/255, alpha: 1) 47 | var searchBarTxtFldBackgroundColor: UIColor = UIColor.clear 48 | var searchBarTxtFldPlaceholderColor: UIColor = UIColor(red: 225/255, green: 225/255, blue: 225/255, alpha: 1) 49 | var searchBarTxtFldPlaceholder: String = "Search with First and Last name" 50 | var searchBarGlassIconTintColor: UIColor = UIColor.white 51 | var searchBarCancelBtnFont: UIFont = UIFont(name: "Helvetica", size: 15)! 52 | var searchBarCancelBtnColor: UIColor = UIColor(red: 64/255, green: 64/255, blue: 64/255, alpha: 1) 53 | 54 | var lastColumnButtonHeaderName = "Edit" 55 | 56 | var delegate: PBDataTableViewDelegate! 57 | 58 | //Setup the tableview with number of Columns and Rows 59 | func setupView() { 60 | 61 | //To Calculate total width of the header view 62 | for eachHeader in columnDataArray { 63 | let eachLblWidth = CGFloat((eachHeader as AnyObject).object(forKey: "widthSize") as! NSNumber) 64 | totalColumnWidth = eachLblWidth + totalColumnWidth 65 | } 66 | 67 | if ApplicationDelegate.cellLastColumnButtonEnable == true { 68 | totalColumnWidth = totalColumnWidth + 80 69 | ApplicationDelegate.numberOfColumns = columnDataArray.count + 1 70 | }else { 71 | ApplicationDelegate.numberOfColumns = columnDataArray.count 72 | } 73 | 74 | if enableSearchBar { 75 | searchBarCustomizeView() 76 | searchBar.isHidden = false 77 | searchBarHeightConstraint.constant = 44 78 | }else { 79 | searchBar.isHidden = true 80 | searchBarHeightConstraint.constant = 0 81 | } 82 | //Create Header View for Tableview 83 | self.createTableHeaderView() 84 | 85 | let nib = UINib(nibName: "PBDataTableViewCell", bundle: nil) 86 | dataTableView.register(nib, forCellReuseIdentifier: "Cell") 87 | } 88 | 89 | //Customize the Search bar 90 | func searchBarCustomizeView() { 91 | // To get a pure color 92 | searchBar.backgroundImage = UIImage() 93 | searchBar.backgroundColor = searchBarBackgroundColor 94 | 95 | let textFieldInsideSearchBar = searchBar.value(forKey: "searchField") as? UITextField 96 | textFieldInsideSearchBar?.textColor = searchBarTxtFldTxtColor 97 | textFieldInsideSearchBar?.font = searchBarTxtFldFont 98 | textFieldInsideSearchBar?.backgroundColor = searchBarTxtFldBackgroundColor 99 | textFieldInsideSearchBar?.tintColor = UIColor.black 100 | textFieldInsideSearchBar?.placeholder = searchBarTxtFldPlaceholder 101 | 102 | let textFieldInsideSearchBarLabel = textFieldInsideSearchBar!.value(forKey: "placeholderLabel") as? UILabel 103 | textFieldInsideSearchBarLabel?.textColor = searchBarTxtFldPlaceholderColor 104 | 105 | if let glassIconView = textFieldInsideSearchBar!.leftView as? UIImageView { 106 | 107 | //Magnifying glass 108 | glassIconView.image = glassIconView.image?.withRenderingMode(UIImageRenderingMode.alwaysTemplate) 109 | glassIconView.tintColor = searchBarGlassIconTintColor 110 | 111 | } 112 | 113 | UIBarButtonItem.appearance(whenContainedInInstancesOf: [UISearchBar.classForCoder() as! UIAppearanceContainer.Type]) 114 | .setTitleTextAttributes([ 115 | NSFontAttributeName: searchBarCancelBtnFont, 116 | NSForegroundColorAttributeName: searchBarCancelBtnColor 117 | ],for: UIControlState()) 118 | } 119 | 120 | //Check the total width and re-size the scrollview.superview width by changing the Trailing Constraint 121 | 122 | func configureView() { 123 | if totalColumnWidth > self.frame.width { 124 | scrollSuperViewTrailingConstraint.constant = (bgScrollView.frame.width-totalColumnWidth) 125 | searchBarTrailingConstraint.constant = 0 126 | 127 | self.updateConstraints() 128 | self.layoutIfNeeded() 129 | 130 | bgScrollView.contentSize = CGSize(width: bgScrollView.frame.width-scrollSuperViewTrailingConstraint.constant, height: self.frame.height-searchBarHeightConstraint.constant) 131 | dataTableView.reloadData() 132 | }else { 133 | tableVwTrailingConstraint.constant = (bgScrollView.frame.width - totalColumnWidth) 134 | headerVwTrailingConstraint.constant = tableVwTrailingConstraint.constant 135 | searchBarTrailingConstraint.constant = tableVwTrailingConstraint.constant 136 | 137 | self.updateConstraints() 138 | self.layoutIfNeeded() 139 | 140 | } 141 | } 142 | 143 | func createTableHeaderView() { 144 | var headerCount = 0 145 | var headerLblXaxis: CGFloat = 0 146 | 147 | for eachHeader in columnDataArray { 148 | 149 | let eachLblWidth = CGFloat((eachHeader as AnyObject).object(forKey: "widthSize") as! NSNumber) 150 | 151 | //Header Label 152 | let columnHeaderLbl = UILabel() 153 | columnHeaderLbl.text = (eachHeader as AnyObject).object(forKey: "name") as? String 154 | columnHeaderLbl.textAlignment = .center 155 | columnHeaderLbl.font = UIFont(name: "Arial", size: 14) 156 | columnHeaderLbl.tag = 1000+headerCount 157 | columnHeaderLbl.textColor = UIColor.white 158 | columnHeaderLbl.adjustsFontSizeToFitWidth = true 159 | tableHeaderView.addSubview(columnHeaderLbl) 160 | 161 | if enableSorting { 162 | columnHeaderLbl.frame = CGRect(x: headerLblXaxis, y: 0, width: eachLblWidth-25, height: tableHeaderView.frame.height) 163 | 164 | //Header Sort ImageView 165 | let sortImg = UIImageView(image: UIImage(named: "none")) 166 | sortImg.accessibilityIdentifier = "0" 167 | 168 | sortImg.frame = CGRect(x: columnHeaderLbl.frame.maxX+5, y: (tableHeaderView.frame.height-sortImg.image!.size.height)/2, width: sortImg.image!.size.width, height: sortImg.image!.size.height) 169 | sortImg.tag = 2000+headerCount 170 | tableHeaderView.addSubview(sortImg) 171 | 172 | //Header Button to Sort the rows on tap 173 | let headerBtn = UIButton(type: .custom) 174 | headerBtn.frame = CGRect(x: columnHeaderLbl.frame.minX, y: 0, width: eachLblWidth, height: columnHeaderLbl.frame.height) 175 | headerBtn.backgroundColor = UIColor.clear 176 | headerBtn.addTarget(self, action: #selector(headerColumnBtnTapped), for: .touchUpInside) 177 | headerBtn.tag = 3000+headerCount 178 | tableHeaderView.addSubview(headerBtn) 179 | }else { 180 | columnHeaderLbl.frame = CGRect(x: headerLblXaxis, y: 0, width: eachLblWidth, height: tableHeaderView.frame.height) 181 | } 182 | headerLblXaxis = eachLblWidth + headerLblXaxis 183 | headerCount += 1 184 | } 185 | 186 | //Add Edit Button On Header 187 | if ApplicationDelegate.cellLastColumnButtonEnable == true { 188 | let editButton = UILabel() 189 | editButton.text = lastColumnButtonHeaderName 190 | editButton.textAlignment = .center 191 | editButton.font = UIFont(name: "Arial", size: 14) 192 | editButton.textColor = UIColor.white 193 | editButton.adjustsFontSizeToFitWidth = true 194 | tableHeaderView.addSubview(editButton) 195 | editButton.frame = CGRect(x: headerLblXaxis, y: 0, width: 70, height: tableHeaderView.frame.height) 196 | } 197 | } 198 | 199 | func editBtnTapped(_ sender: UIButton) { 200 | let btnPosition = sender.convert(CGPoint.zero, to: dataTableView) 201 | let selectedIndex = dataTableView.indexPathForRow(at: btnPosition) 202 | 203 | delegate.tableViewCellEditButtonTapped(selectedIndex!) 204 | } 205 | 206 | func headerColumnBtnTapped(_ sender: UIButton) { 207 | for i in 0.. Int { 249 | if shouldShowSearchResults { 250 | if filteredDataTableArray.count > 0 { 251 | noRecordLbl.isHidden = true 252 | dataTableView.isHidden = false 253 | }else { 254 | noRecordLbl.isHidden = false 255 | dataTableView.isHidden = true 256 | } 257 | return filteredDataTableArray.count 258 | }else { 259 | if dataTableArray.count > 0 { 260 | noRecordLbl.isHidden = true 261 | dataTableView.isHidden = false 262 | }else { 263 | noRecordLbl.isHidden = false 264 | dataTableView.isHidden = true 265 | } 266 | return dataTableArray.count 267 | } 268 | } 269 | 270 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 271 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! PBDataTableViewCell 272 | 273 | cell.backgroundColor = UIColor.white 274 | configureCell(cell, indexPath: indexPath) 275 | 276 | if enableCellOuterBorder { 277 | cell.leftBorderView.isHidden = false 278 | cell.rightBorderView.isHidden = false 279 | cell.bottomBorderView.isHidden = false 280 | }else { 281 | cell.leftBorderView.isHidden = true 282 | cell.rightBorderView.isHidden = true 283 | cell.bottomBorderView.isHidden = true 284 | } 285 | return cell 286 | } 287 | 288 | //Configure Tableview Cells with Defined Label 289 | func configureCell(_ cell: PBDataTableViewCell, indexPath: IndexPath) { 290 | let columnDict: NSDictionary! 291 | 292 | if shouldShowSearchResults { 293 | columnDict = filteredDataTableArray.object(at: (indexPath as NSIndexPath).row) as! NSDictionary 294 | }else { 295 | columnDict = dataTableArray.object(at: (indexPath as NSIndexPath).row) as! NSDictionary 296 | } 297 | var labelXaxis: CGFloat = 0 298 | 299 | for i in 0.. CGFloat { 342 | return 44 343 | } 344 | 345 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 346 | delegate.tableViewDidSelectedRow(indexPath) 347 | } 348 | } 349 | 350 | //MARK: - Search Bar Delegate 351 | extension PBDataTableView: UISearchBarDelegate, UISearchControllerDelegate { 352 | func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) { 353 | shouldShowSearchResults = true 354 | searchBar.showsCancelButton = true 355 | } 356 | 357 | 358 | func searchBarCancelButtonClicked(_ searchBar: UISearchBar) { 359 | searchBar.showsCancelButton = false 360 | shouldShowSearchResults = false 361 | searchBar.text = "" 362 | searchBar.resignFirstResponder() 363 | dataTableView.reloadData() 364 | } 365 | 366 | func searchBarSearchButtonClicked(_ searchBar: UISearchBar) { 367 | if !shouldShowSearchResults { 368 | shouldShowSearchResults = true 369 | dataTableView.reloadData() 370 | } 371 | searchBar.resignFirstResponder() 372 | } 373 | 374 | func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { 375 | 376 | if searchText == "" { 377 | shouldShowSearchResults = false 378 | }else { 379 | shouldShowSearchResults = true 380 | //filtered with firstname and last name. Give the column names respectively to be sorted 381 | let results = dataTableArray.filter({ person in 382 | let personDict = person as! NSDictionary 383 | if let firstname = personDict["rowColumn1"] as? String, let lastname = personDict["rowColumn2"] as? String, let query = searchBar.text { 384 | return firstname.range(of: query, options: [.caseInsensitive, .diacriticInsensitive]) != nil || lastname.range(of: query, options: [.caseInsensitive, .diacriticInsensitive]) != nil 385 | } 386 | return false 387 | }) 388 | filteredDataTableArray = NSMutableArray(array: results) 389 | } 390 | dataTableView.reloadData() 391 | } 392 | } 393 | -------------------------------------------------------------------------------- /PBDataTable/Classes/PBDataTableView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /PBDataTable/Classes/PBDataTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PBDataTableViewCell.swift 3 | // PBDataTable 4 | // 5 | // Created by praveen b on 6/10/16. 6 | // Copyright © 2016 Praveen. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class PBDataTableViewCell: UITableViewCell { 12 | var columnWidth: CGFloat = 80 13 | 14 | @IBOutlet var leftBorderView: UIView! 15 | @IBOutlet var rightBorderView: UIView! 16 | @IBOutlet var bottomBorderView: UIView! 17 | 18 | override func awakeFromNib() { 19 | super.awakeFromNib() 20 | // Initialization code 21 | 22 | var labelXaxis: CGFloat = 0 23 | 24 | for i in 0.. 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /PBDataTable/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIViewControllerBasedStatusBarAppearance 6 | 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /PBDataTable/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // PBDataTable 4 | // 5 | // Created by praveen b on 6/10/16. 6 | // Copyright © 2016 Praveen. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController, PBDataTableViewDelegate { 12 | var dataTableView: PBDataTableView! 13 | 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | // Do any additional setup after loading the view, typically from a nib. 17 | 18 | changeStatusBarColor() 19 | 20 | dataTableView = Bundle.main.loadNibNamed("PBDataTableView", owner: self, options: nil)?.first as! PBDataTableView 21 | dataTableView.frame = CGRect(x: 0, y: 20, width: self.view.frame.width, height: self.view.frame.height-20) 22 | dataTableView.backgroundColor = UIColor(red: 225/255, green: 225/255, blue: 225/255, alpha: 1.0) 23 | dataTableView.delegate = self 24 | dataTableView.enableSorting = true 25 | 26 | //Search bar can be customized, now it was set to default value. Search is enabled with first 2 columns. 27 | dataTableView.enableSearchBar = true 28 | 29 | //Header name and width size can be dynamic. Table view will be re-sized respectively, if total width exceeds the Super view Width table view will be scrolled. 30 | dataTableView.columnDataArray = [["name":"FirstName","widthSize":110],["name":"LastName","widthSize":110],["name":"Address","widthSize":180],["name":"City","widthSize":110],["name":"Zip","widthSize":100],["name":"PhoneNumber","widthSize":158]] 31 | 32 | //Not to change the Key of the Dictionaries if needs to be dynamic. 33 | dataTableView.dataTableArray = dataTableViewdictParams() 34 | 35 | //Only if you want the Last column to be button make use of below two lines of code. You can cutomize the Button from PBDataTableViewCell. 36 | ApplicationDelegate.cellLastColumnButtonEnable = true 37 | dataTableView.lastColumnButtonHeaderName = "Edit" 38 | 39 | dataTableView.setupView() 40 | self.view.addSubview(dataTableView) 41 | } 42 | 43 | override func viewDidAppear(_ animated: Bool) { 44 | //T0 change the Constraints and make the view scrollable make sure you add this line in View Did Appear. 45 | dataTableView.configureView() 46 | } 47 | 48 | func tableViewDidSelectedRow(_ indexPath: IndexPath) { 49 | print("selected row: \(indexPath)") 50 | } 51 | 52 | func tableViewCellEditButtonTapped(_ indexPath: IndexPath) { 53 | print("selected row: \(indexPath)") 54 | } 55 | 56 | func changeStatusBarColor() { 57 | UIApplication.shared.isStatusBarHidden = false 58 | UIApplication.shared.statusBarStyle = .lightContent 59 | 60 | let statusBar: UIView = UIApplication.shared.value(forKey: "statusBar") as! UIView 61 | statusBar.backgroundColor = UIColor(red: 64/255, green: 64/255, blue: 64/255, alpha: 1) 62 | } 63 | 64 | func dataTableViewdictParams() -> NSMutableArray { 65 | let dataTableArray = [ 66 | ["rowColumn1":"Ajay","rowColumn2":"Zener","rowColumn3":"23, Settembre","rowColumn4":"Rome","rowColumn5":NSNumber(value: 80099 as Int),"rowColumn6":NumberFormatter().number(from: "6766665")!], 67 | 68 | ["rowColumn1":"Peter","rowColumn2":"Hayes","rowColumn3":"Richmond Street","rowColumn4":"Hoboken","rowColumn5":NSNumber(value: 50043 as Int),"rowColumn6":NumberFormatter().number(from: "8676766665")!], 69 | 70 | ["rowColumn1":"Aaron","rowColumn2":"Joe","rowColumn3":"Goodman Susan E, 42 Grove St","rowColumn4":"NewYork","rowColumn5":NSNumber(value: 10014 as Int),"rowColumn6":NumberFormatter().number(from: "9889499449")!], 71 | 72 | ["rowColumn1":"Gabriel","rowColumn2":"Ella","rowColumn3":"9 Barrow Owners Corporation","rowColumn4":"NewYork","rowColumn5":NSNumber(value: 10033 as Int),"rowColumn6":NumberFormatter().number(from: "5676667667")!], 73 | ["rowColumn1":"Matthew","rowColumn2":"William","rowColumn3":"401-505 LaGuardia Pl","rowColumn4":"NewYork","rowColumn5":NSNumber(value: 10011 as Int),"rowColumn6":NumberFormatter().number(from: "8099078771")!], 74 | ["rowColumn1":"Scarlett","rowColumn2":"","rowColumn3":"301 Garden St Hoboken","rowColumn4":"Hoboken","rowColumn5":NSNumber(value: 10022 as Int),"rowColumn6":NumberFormatter().number(from: "4323445555")!], 75 | ["rowColumn1":"Hannah","rowColumn2":"Andrew","rowColumn3":"Sixteenth St Jersey City","rowColumn4":"New Jersey","rowColumn5":NSNumber(value: 13222 as Int),"rowColumn6":NumberFormatter().number(from: "7666676555")!], 76 | ["rowColumn1":"Alexa","rowColumn2":"Joe","rowColumn3":"211 County Ave Secaucus","rowColumn4":"New Jersey","rowColumn5":NSNumber(value: 12022 as Int),"rowColumn6":NumberFormatter().number(from: "9889888888")!], 77 | ["rowColumn1":"Hunter","rowColumn2":"Ryan","rowColumn3":"Edgmont Township","rowColumn4":"Philadelphia","rowColumn5":NSNumber(value: 11001 as Int),"rowColumn6":NumberFormatter().number(from: "6567766776")!], 78 | ["rowColumn1":"Lucy","rowColumn2":"Adrian","rowColumn3":"Secaucus, NJ","rowColumn4":"New Jersey","rowColumn5":NSNumber(value: 10003 as Int),"rowColumn6":NumberFormatter().number(from: "7455455551")!]] as NSMutableArray 79 | 80 | return dataTableArray 81 | } 82 | 83 | override func didReceiveMemoryWarning() { 84 | super.didReceiveMemoryWarning() 85 | // Dispose of any resources that can be recreated. 86 | } 87 | } 88 | 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PBDataTableView 2 | DataTable for iPhone and iPad 3 | 4 | An easy-to-use PBDataTableView with sorting and search option. 5 | 6 | ## Quick Start 7 |
8 | 1. Drop PBDataTableView.swift and PBDataTableViewCell.swift with their respective xib files.
9 | 2. Intialize the xib file on your view controller.
10 | 3. Set up the PBDataTableView with frame and customize the search bar.
11 | 4. The Header of the Tableview given to "columnDataArray" with name of the header and the width size of the each header. (If total width of the header exceeds its superview the view will be scrolled horizontally.)
12 | 5. The Row content of the Tableview given to "dataTableArray" as shown in ViewController.
13 | NOTE* It will be easy if you dont change the dictionay key. If you need to change the Keys, please make the change on "PBDataTableView" too. 14 | 15 | ![Alt text](https://github.com/praveenb-ios/PBDataTableView/blob/master/iPAD_DataTableView.png "DataTableView_iPad") 16 | 17 | ## The MIT License (MIT) 18 | 19 | Copyright (c) 2016 Praveen B
20 | 21 | 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:

22 | 23 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
24 | 25 | 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. 26 | -------------------------------------------------------------------------------- /iPAD_DataTableView.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/praveenb-ios/PBDataTableView/a992e74cb071d4d81f1d167dfaf1e804e2ac8a92/iPAD_DataTableView.png --------------------------------------------------------------------------------