├── README.md ├── UITableViewRowEditIcon.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── larrymacfadyen.xcuserdatad │ └── xcschemes │ ├── UITableViewRowEditIcon.xcscheme │ └── xcschememanagement.plist └── UITableViewRowEditIcon ├── AppDelegate.swift ├── Assets.xcassets ├── AppIcon.appiconset │ └── Contents.json ├── Contents.json └── EditIcon.imageset │ ├── Contents.json │ ├── EditButtonIcon.png │ ├── EditButtonIcon@2x.png │ └── EditButtonIcon@3x.png ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Book.swift ├── BookTableViewCell.swift ├── EditButtonIcon.png ├── EditButtonIcon@2x.png ├── EditButtonIcon@3x.png ├── Info.plist ├── TableWithEditIconsController.swift └── ViewController.swift /README.md: -------------------------------------------------------------------------------- 1 | # UITableViewRowEditIcon 2 | Custom Edit Button on Each Row With Icon When UITableView is in Edit Mode 3 | 4 | This project accompanies my tutorial here: http://www.iosinsight.com/uitableview-custom-edit-button-in-each-row-with-swift/ 5 | 6 | Implemented with Swift 2.0 and xCode 7.1. 7 | -------------------------------------------------------------------------------- /UITableViewRowEditIcon.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 110894891BE15B680099BFCB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 110894881BE15B680099BFCB /* AppDelegate.swift */; }; 11 | 1108948B1BE15B680099BFCB /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1108948A1BE15B680099BFCB /* ViewController.swift */; }; 12 | 1108948E1BE15B680099BFCB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1108948C1BE15B680099BFCB /* Main.storyboard */; }; 13 | 110894901BE15B680099BFCB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1108948F1BE15B680099BFCB /* Assets.xcassets */; }; 14 | 110894931BE15B680099BFCB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 110894911BE15B680099BFCB /* LaunchScreen.storyboard */; }; 15 | 1108949C1BE15E810099BFCB /* Book.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1108949B1BE15E810099BFCB /* Book.swift */; }; 16 | 1108949E1BE15EFD0099BFCB /* TableWithEditIconsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1108949D1BE15EFD0099BFCB /* TableWithEditIconsController.swift */; }; 17 | 110894A41BE169050099BFCB /* BookTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 110894A31BE169050099BFCB /* BookTableViewCell.swift */; }; 18 | 110894A81BE16E8E0099BFCB /* EditButtonIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 110894A51BE16E8E0099BFCB /* EditButtonIcon.png */; }; 19 | 110894A91BE16E8E0099BFCB /* EditButtonIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 110894A61BE16E8E0099BFCB /* EditButtonIcon@2x.png */; }; 20 | 110894AA1BE16E8E0099BFCB /* EditButtonIcon@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 110894A71BE16E8E0099BFCB /* EditButtonIcon@3x.png */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | 110894851BE15B680099BFCB /* UITableViewRowEditIcon.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UITableViewRowEditIcon.app; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | 110894881BE15B680099BFCB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 26 | 1108948A1BE15B680099BFCB /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 27 | 1108948D1BE15B680099BFCB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 28 | 1108948F1BE15B680099BFCB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 29 | 110894921BE15B680099BFCB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 30 | 110894941BE15B680099BFCB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | 1108949B1BE15E810099BFCB /* Book.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Book.swift; sourceTree = ""; }; 32 | 1108949D1BE15EFD0099BFCB /* TableWithEditIconsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableWithEditIconsController.swift; sourceTree = ""; }; 33 | 110894A31BE169050099BFCB /* BookTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookTableViewCell.swift; sourceTree = ""; }; 34 | 110894A51BE16E8E0099BFCB /* EditButtonIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = EditButtonIcon.png; sourceTree = ""; }; 35 | 110894A61BE16E8E0099BFCB /* EditButtonIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "EditButtonIcon@2x.png"; sourceTree = ""; }; 36 | 110894A71BE16E8E0099BFCB /* EditButtonIcon@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "EditButtonIcon@3x.png"; sourceTree = ""; }; 37 | /* End PBXFileReference section */ 38 | 39 | /* Begin PBXFrameworksBuildPhase section */ 40 | 110894821BE15B680099BFCB /* Frameworks */ = { 41 | isa = PBXFrameworksBuildPhase; 42 | buildActionMask = 2147483647; 43 | files = ( 44 | ); 45 | runOnlyForDeploymentPostprocessing = 0; 46 | }; 47 | /* End PBXFrameworksBuildPhase section */ 48 | 49 | /* Begin PBXGroup section */ 50 | 1108947C1BE15B670099BFCB = { 51 | isa = PBXGroup; 52 | children = ( 53 | 110894871BE15B680099BFCB /* UITableViewRowEditIcon */, 54 | 110894861BE15B680099BFCB /* Products */, 55 | ); 56 | sourceTree = ""; 57 | }; 58 | 110894861BE15B680099BFCB /* Products */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 110894851BE15B680099BFCB /* UITableViewRowEditIcon.app */, 62 | ); 63 | name = Products; 64 | sourceTree = ""; 65 | }; 66 | 110894871BE15B680099BFCB /* UITableViewRowEditIcon */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 110894881BE15B680099BFCB /* AppDelegate.swift */, 70 | 1108948A1BE15B680099BFCB /* ViewController.swift */, 71 | 1108949D1BE15EFD0099BFCB /* TableWithEditIconsController.swift */, 72 | 110894A31BE169050099BFCB /* BookTableViewCell.swift */, 73 | 1108949B1BE15E810099BFCB /* Book.swift */, 74 | 1108948C1BE15B680099BFCB /* Main.storyboard */, 75 | 1108948F1BE15B680099BFCB /* Assets.xcassets */, 76 | 110894911BE15B680099BFCB /* LaunchScreen.storyboard */, 77 | 110894941BE15B680099BFCB /* Info.plist */, 78 | 1108949A1BE15B760099BFCB /* Images */, 79 | ); 80 | path = UITableViewRowEditIcon; 81 | sourceTree = ""; 82 | }; 83 | 1108949A1BE15B760099BFCB /* Images */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 110894A51BE16E8E0099BFCB /* EditButtonIcon.png */, 87 | 110894A61BE16E8E0099BFCB /* EditButtonIcon@2x.png */, 88 | 110894A71BE16E8E0099BFCB /* EditButtonIcon@3x.png */, 89 | ); 90 | name = Images; 91 | sourceTree = ""; 92 | }; 93 | /* End PBXGroup section */ 94 | 95 | /* Begin PBXNativeTarget section */ 96 | 110894841BE15B680099BFCB /* UITableViewRowEditIcon */ = { 97 | isa = PBXNativeTarget; 98 | buildConfigurationList = 110894971BE15B680099BFCB /* Build configuration list for PBXNativeTarget "UITableViewRowEditIcon" */; 99 | buildPhases = ( 100 | 110894811BE15B680099BFCB /* Sources */, 101 | 110894821BE15B680099BFCB /* Frameworks */, 102 | 110894831BE15B680099BFCB /* Resources */, 103 | ); 104 | buildRules = ( 105 | ); 106 | dependencies = ( 107 | ); 108 | name = UITableViewRowEditIcon; 109 | productName = UITableViewRowEditIcon; 110 | productReference = 110894851BE15B680099BFCB /* UITableViewRowEditIcon.app */; 111 | productType = "com.apple.product-type.application"; 112 | }; 113 | /* End PBXNativeTarget section */ 114 | 115 | /* Begin PBXProject section */ 116 | 1108947D1BE15B670099BFCB /* Project object */ = { 117 | isa = PBXProject; 118 | attributes = { 119 | LastSwiftUpdateCheck = 0710; 120 | LastUpgradeCheck = 1150; 121 | ORGANIZATIONNAME = LawrenceM; 122 | TargetAttributes = { 123 | 110894841BE15B680099BFCB = { 124 | CreatedOnToolsVersion = 7.1; 125 | LastSwiftMigration = 1150; 126 | }; 127 | }; 128 | }; 129 | buildConfigurationList = 110894801BE15B670099BFCB /* Build configuration list for PBXProject "UITableViewRowEditIcon" */; 130 | compatibilityVersion = "Xcode 3.2"; 131 | developmentRegion = en; 132 | hasScannedForEncodings = 0; 133 | knownRegions = ( 134 | en, 135 | Base, 136 | ); 137 | mainGroup = 1108947C1BE15B670099BFCB; 138 | productRefGroup = 110894861BE15B680099BFCB /* Products */; 139 | projectDirPath = ""; 140 | projectRoot = ""; 141 | targets = ( 142 | 110894841BE15B680099BFCB /* UITableViewRowEditIcon */, 143 | ); 144 | }; 145 | /* End PBXProject section */ 146 | 147 | /* Begin PBXResourcesBuildPhase section */ 148 | 110894831BE15B680099BFCB /* Resources */ = { 149 | isa = PBXResourcesBuildPhase; 150 | buildActionMask = 2147483647; 151 | files = ( 152 | 110894AA1BE16E8E0099BFCB /* EditButtonIcon@3x.png in Resources */, 153 | 110894A81BE16E8E0099BFCB /* EditButtonIcon.png in Resources */, 154 | 110894931BE15B680099BFCB /* LaunchScreen.storyboard in Resources */, 155 | 110894901BE15B680099BFCB /* Assets.xcassets in Resources */, 156 | 1108948E1BE15B680099BFCB /* Main.storyboard in Resources */, 157 | 110894A91BE16E8E0099BFCB /* EditButtonIcon@2x.png in Resources */, 158 | ); 159 | runOnlyForDeploymentPostprocessing = 0; 160 | }; 161 | /* End PBXResourcesBuildPhase section */ 162 | 163 | /* Begin PBXSourcesBuildPhase section */ 164 | 110894811BE15B680099BFCB /* Sources */ = { 165 | isa = PBXSourcesBuildPhase; 166 | buildActionMask = 2147483647; 167 | files = ( 168 | 1108948B1BE15B680099BFCB /* ViewController.swift in Sources */, 169 | 110894891BE15B680099BFCB /* AppDelegate.swift in Sources */, 170 | 1108949C1BE15E810099BFCB /* Book.swift in Sources */, 171 | 110894A41BE169050099BFCB /* BookTableViewCell.swift in Sources */, 172 | 1108949E1BE15EFD0099BFCB /* TableWithEditIconsController.swift in Sources */, 173 | ); 174 | runOnlyForDeploymentPostprocessing = 0; 175 | }; 176 | /* End PBXSourcesBuildPhase section */ 177 | 178 | /* Begin PBXVariantGroup section */ 179 | 1108948C1BE15B680099BFCB /* Main.storyboard */ = { 180 | isa = PBXVariantGroup; 181 | children = ( 182 | 1108948D1BE15B680099BFCB /* Base */, 183 | ); 184 | name = Main.storyboard; 185 | sourceTree = ""; 186 | }; 187 | 110894911BE15B680099BFCB /* LaunchScreen.storyboard */ = { 188 | isa = PBXVariantGroup; 189 | children = ( 190 | 110894921BE15B680099BFCB /* Base */, 191 | ); 192 | name = LaunchScreen.storyboard; 193 | sourceTree = ""; 194 | }; 195 | /* End PBXVariantGroup section */ 196 | 197 | /* Begin XCBuildConfiguration section */ 198 | 110894951BE15B680099BFCB /* Debug */ = { 199 | isa = XCBuildConfiguration; 200 | buildSettings = { 201 | ALWAYS_SEARCH_USER_PATHS = NO; 202 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 203 | CLANG_CXX_LIBRARY = "libc++"; 204 | CLANG_ENABLE_MODULES = YES; 205 | CLANG_ENABLE_OBJC_ARC = YES; 206 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 207 | CLANG_WARN_BOOL_CONVERSION = YES; 208 | CLANG_WARN_COMMA = YES; 209 | CLANG_WARN_CONSTANT_CONVERSION = YES; 210 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 211 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 212 | CLANG_WARN_EMPTY_BODY = YES; 213 | CLANG_WARN_ENUM_CONVERSION = YES; 214 | CLANG_WARN_INFINITE_RECURSION = YES; 215 | CLANG_WARN_INT_CONVERSION = YES; 216 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 217 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 218 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 219 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 220 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 221 | CLANG_WARN_STRICT_PROTOTYPES = YES; 222 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 223 | CLANG_WARN_UNREACHABLE_CODE = YES; 224 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 225 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 226 | COPY_PHASE_STRIP = NO; 227 | DEBUG_INFORMATION_FORMAT = dwarf; 228 | ENABLE_STRICT_OBJC_MSGSEND = YES; 229 | ENABLE_TESTABILITY = YES; 230 | GCC_C_LANGUAGE_STANDARD = gnu99; 231 | GCC_DYNAMIC_NO_PIC = NO; 232 | GCC_NO_COMMON_BLOCKS = YES; 233 | GCC_OPTIMIZATION_LEVEL = 0; 234 | GCC_PREPROCESSOR_DEFINITIONS = ( 235 | "DEBUG=1", 236 | "$(inherited)", 237 | ); 238 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 239 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 240 | GCC_WARN_UNDECLARED_SELECTOR = YES; 241 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 242 | GCC_WARN_UNUSED_FUNCTION = YES; 243 | GCC_WARN_UNUSED_VARIABLE = YES; 244 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 245 | MTL_ENABLE_DEBUG_INFO = YES; 246 | ONLY_ACTIVE_ARCH = YES; 247 | SDKROOT = iphoneos; 248 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 249 | TARGETED_DEVICE_FAMILY = "1,2"; 250 | }; 251 | name = Debug; 252 | }; 253 | 110894961BE15B680099BFCB /* Release */ = { 254 | isa = XCBuildConfiguration; 255 | buildSettings = { 256 | ALWAYS_SEARCH_USER_PATHS = NO; 257 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 258 | CLANG_CXX_LIBRARY = "libc++"; 259 | CLANG_ENABLE_MODULES = YES; 260 | CLANG_ENABLE_OBJC_ARC = YES; 261 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 262 | CLANG_WARN_BOOL_CONVERSION = YES; 263 | CLANG_WARN_COMMA = YES; 264 | CLANG_WARN_CONSTANT_CONVERSION = YES; 265 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 266 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 267 | CLANG_WARN_EMPTY_BODY = YES; 268 | CLANG_WARN_ENUM_CONVERSION = YES; 269 | CLANG_WARN_INFINITE_RECURSION = YES; 270 | CLANG_WARN_INT_CONVERSION = YES; 271 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 272 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 273 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 274 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 275 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 276 | CLANG_WARN_STRICT_PROTOTYPES = YES; 277 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 278 | CLANG_WARN_UNREACHABLE_CODE = YES; 279 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 280 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 281 | COPY_PHASE_STRIP = NO; 282 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 283 | ENABLE_NS_ASSERTIONS = NO; 284 | ENABLE_STRICT_OBJC_MSGSEND = YES; 285 | GCC_C_LANGUAGE_STANDARD = gnu99; 286 | GCC_NO_COMMON_BLOCKS = YES; 287 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 288 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 289 | GCC_WARN_UNDECLARED_SELECTOR = YES; 290 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 291 | GCC_WARN_UNUSED_FUNCTION = YES; 292 | GCC_WARN_UNUSED_VARIABLE = YES; 293 | IPHONEOS_DEPLOYMENT_TARGET = 9.1; 294 | MTL_ENABLE_DEBUG_INFO = NO; 295 | SDKROOT = iphoneos; 296 | SWIFT_COMPILATION_MODE = wholemodule; 297 | TARGETED_DEVICE_FAMILY = "1,2"; 298 | VALIDATE_PRODUCT = YES; 299 | }; 300 | name = Release; 301 | }; 302 | 110894981BE15B680099BFCB /* Debug */ = { 303 | isa = XCBuildConfiguration; 304 | buildSettings = { 305 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 306 | INFOPLIST_FILE = UITableViewRowEditIcon/Info.plist; 307 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 308 | PRODUCT_BUNDLE_IDENTIFIER = com.lawrencem.UITableViewRowEditIcon; 309 | PRODUCT_NAME = "$(TARGET_NAME)"; 310 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 311 | SWIFT_VERSION = 5.0; 312 | }; 313 | name = Debug; 314 | }; 315 | 110894991BE15B680099BFCB /* Release */ = { 316 | isa = XCBuildConfiguration; 317 | buildSettings = { 318 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 319 | INFOPLIST_FILE = UITableViewRowEditIcon/Info.plist; 320 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 321 | PRODUCT_BUNDLE_IDENTIFIER = com.lawrencem.UITableViewRowEditIcon; 322 | PRODUCT_NAME = "$(TARGET_NAME)"; 323 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 324 | SWIFT_VERSION = 5.0; 325 | }; 326 | name = Release; 327 | }; 328 | /* End XCBuildConfiguration section */ 329 | 330 | /* Begin XCConfigurationList section */ 331 | 110894801BE15B670099BFCB /* Build configuration list for PBXProject "UITableViewRowEditIcon" */ = { 332 | isa = XCConfigurationList; 333 | buildConfigurations = ( 334 | 110894951BE15B680099BFCB /* Debug */, 335 | 110894961BE15B680099BFCB /* Release */, 336 | ); 337 | defaultConfigurationIsVisible = 0; 338 | defaultConfigurationName = Release; 339 | }; 340 | 110894971BE15B680099BFCB /* Build configuration list for PBXNativeTarget "UITableViewRowEditIcon" */ = { 341 | isa = XCConfigurationList; 342 | buildConfigurations = ( 343 | 110894981BE15B680099BFCB /* Debug */, 344 | 110894991BE15B680099BFCB /* Release */, 345 | ); 346 | defaultConfigurationIsVisible = 0; 347 | defaultConfigurationName = Release; 348 | }; 349 | /* End XCConfigurationList section */ 350 | }; 351 | rootObject = 1108947D1BE15B670099BFCB /* Project object */; 352 | } 353 | -------------------------------------------------------------------------------- /UITableViewRowEditIcon.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /UITableViewRowEditIcon.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /UITableViewRowEditIcon.xcodeproj/xcuserdata/larrymacfadyen.xcuserdatad/xcschemes/UITableViewRowEditIcon.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /UITableViewRowEditIcon.xcodeproj/xcuserdata/larrymacfadyen.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | UITableViewRowEditIcon.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 110894841BE15B680099BFCB 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /UITableViewRowEditIcon/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // UITableViewRowEditIcon 4 | // 5 | // Created by Lawrence F MacFadyen on 2015-10-28. 6 | // Copyright © 2015 LawrenceM. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /UITableViewRowEditIcon/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /UITableViewRowEditIcon/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /UITableViewRowEditIcon/Assets.xcassets/EditIcon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "EditButtonIcon.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "EditButtonIcon@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "EditButtonIcon@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | }, 23 | "properties" : { 24 | "template-rendering-intent" : "template" 25 | } 26 | } -------------------------------------------------------------------------------- /UITableViewRowEditIcon/Assets.xcassets/EditIcon.imageset/EditButtonIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmacfadyen/UITableViewRowEditIcon/cce16b2804a69668c6845a1e4bf746cb6aa81f3a/UITableViewRowEditIcon/Assets.xcassets/EditIcon.imageset/EditButtonIcon.png -------------------------------------------------------------------------------- /UITableViewRowEditIcon/Assets.xcassets/EditIcon.imageset/EditButtonIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmacfadyen/UITableViewRowEditIcon/cce16b2804a69668c6845a1e4bf746cb6aa81f3a/UITableViewRowEditIcon/Assets.xcassets/EditIcon.imageset/EditButtonIcon@2x.png -------------------------------------------------------------------------------- /UITableViewRowEditIcon/Assets.xcassets/EditIcon.imageset/EditButtonIcon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmacfadyen/UITableViewRowEditIcon/cce16b2804a69668c6845a1e4bf746cb6aa81f3a/UITableViewRowEditIcon/Assets.xcassets/EditIcon.imageset/EditButtonIcon@3x.png -------------------------------------------------------------------------------- /UITableViewRowEditIcon/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 | -------------------------------------------------------------------------------- /UITableViewRowEditIcon/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 | 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 | 61 | 62 | 63 | 64 | 65 | 76 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | -------------------------------------------------------------------------------- /UITableViewRowEditIcon/Book.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Book.swift 3 | // UITableViewRowEditIcon 4 | // 5 | // Created by Lawrence F MacFadyen on 2015-10-28. 6 | // Copyright © 2015 LawrenceM. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct Book { 12 | var title: String 13 | var author: String 14 | 15 | init(title: String, author: String) { 16 | self.title = title 17 | self.author = author 18 | } 19 | } -------------------------------------------------------------------------------- /UITableViewRowEditIcon/BookTableViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BookTableViewCell.swift 3 | // UITableViewRowEditIcon 4 | // 5 | // Created by Lawrence F MacFadyen on 2015-10-28. 6 | // Copyright © 2015 LawrenceM. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class BookTableViewCell: UITableViewCell { 12 | 13 | @IBOutlet weak var buttonWidth: NSLayoutConstraint! 14 | @IBOutlet weak var buttonView: UIView! 15 | @IBOutlet weak var titleLabel: UILabel! 16 | @IBOutlet weak var authorLabel: UILabel! 17 | 18 | override func awakeFromNib() { 19 | super.awakeFromNib() 20 | // Initialization code 21 | } 22 | 23 | override func setSelected(_ selected: Bool, animated: Bool) { 24 | super.setSelected(selected, animated: animated) 25 | 26 | // Configure the view for the selected state 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /UITableViewRowEditIcon/EditButtonIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmacfadyen/UITableViewRowEditIcon/cce16b2804a69668c6845a1e4bf746cb6aa81f3a/UITableViewRowEditIcon/EditButtonIcon.png -------------------------------------------------------------------------------- /UITableViewRowEditIcon/EditButtonIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmacfadyen/UITableViewRowEditIcon/cce16b2804a69668c6845a1e4bf746cb6aa81f3a/UITableViewRowEditIcon/EditButtonIcon@2x.png -------------------------------------------------------------------------------- /UITableViewRowEditIcon/EditButtonIcon@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lmacfadyen/UITableViewRowEditIcon/cce16b2804a69668c6845a1e4bf746cb6aa81f3a/UITableViewRowEditIcon/EditButtonIcon@3x.png -------------------------------------------------------------------------------- /UITableViewRowEditIcon/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /UITableViewRowEditIcon/TableWithEditIconsController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TableWithEditIconsController.swift 3 | // UITableViewRowEditIcon 4 | // 5 | // Created by Lawrence F MacFadyen on 2015-10-28. 6 | // Copyright © 2015 LawrenceM. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class TableWithEditIconsController: UITableViewController { 12 | 13 | var books = [Book(title: "The Swift Programming Language (Swift 2)", author: "Apple Inc."), Book(title: "Swift Algorithms and Data Structures", author: "Wayne Bishop"), Book(title: "Advanced Swift", author: "Chris Eidhof/Airspeed Velocity"), Book(title: "iOS Programming", author: "Big Nerd Ranch"), Book(title: "Test-Driven iOS Development With Swift", author: "Dr. Dominik Hauser") ] 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | tableView.estimatedRowHeight = 56.0 19 | tableView.rowHeight = UITableView.automaticDimension 20 | 21 | self.navigationItem.rightBarButtonItem = self.editButtonItem 22 | } 23 | 24 | override func viewWillAppear(_ animated: Bool) { 25 | setEditing(false, animated: true) 26 | } 27 | 28 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 29 | 30 | let cell:BookTableViewCell = tableView.dequeueReusableCell(withIdentifier: "bookCell") as! BookTableViewCell 31 | 32 | let book = books[indexPath.row] 33 | 34 | cell.authorLabel.text = "- " + book.author 35 | cell.titleLabel.text = book.title 36 | 37 | if(tableView.isEditing && self.tableView(tableView, canEditRowAt: indexPath)) 38 | { 39 | cell.buttonView.isHidden = false 40 | cell.buttonWidth.constant = cell.bounds.size.width * 0.1 41 | } 42 | else 43 | { 44 | cell.buttonWidth.constant = 0 45 | cell.buttonView.isHidden = true 46 | } 47 | 48 | return cell 49 | } 50 | 51 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 52 | return books.count 53 | } 54 | 55 | 56 | override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { 57 | return true 58 | } 59 | 60 | override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { 61 | if editingStyle == .delete { 62 | books.remove(at: indexPath.row) 63 | tableView.reloadData() 64 | } 65 | } 66 | 67 | override func setEditing(_ editing: Bool, animated: Bool) { 68 | super.setEditing(editing, animated: animated) 69 | tableView.reloadData() 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /UITableViewRowEditIcon/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // UITableViewRowEditIcon 4 | // 5 | // Created by Lawrence F MacFadyen on 2015-10-28. 6 | // Copyright © 2015 LawrenceM. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | // Do any additional setup after loading the view, typically from a nib. 16 | } 17 | 18 | override func didReceiveMemoryWarning() { 19 | super.didReceiveMemoryWarning() 20 | // Dispose of any resources that can be recreated. 21 | } 22 | 23 | 24 | } 25 | 26 | --------------------------------------------------------------------------------