├── .gitignore ├── Default-568h@2x.png ├── PickerCellDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ ├── michael.xcuserdatad │ └── xcschemes │ │ ├── PickerCellDemo.xcscheme │ │ └── xcschememanagement.plist │ └── tom.xcuserdatad │ └── xcschemes │ ├── PickerCellDemo.xcscheme │ └── xcschememanagement.plist ├── PickerCellDemo ├── AppDelegate.h ├── AppDelegate.m ├── CustomUIPickerView.h ├── CustomUIPickerView.m ├── DateInputTableViewCell.h ├── DateInputTableViewCell.m ├── IntegerInputTableViewCell.h ├── IntegerInputTableViewCell.m ├── PickerCellDemo-Info.plist ├── PickerCellDemo-Prefix.pch ├── PickerInputTableViewCell.h ├── PickerInputTableViewCell.m ├── SimplePickerInputTableViewCell.h ├── SimplePickerInputTableViewCell.m ├── StringInputTableViewCell.h ├── StringInputTableViewCell.m ├── UIColor+Custom.h ├── UIColor+Custom.m ├── ViewController.h ├── ViewController.m ├── en.lproj │ ├── InfoPlist.strings │ ├── MainStoryboard_iPad.storyboard │ └── MainStoryboard_iPhone.storyboard └── main.m └── README /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | PickerCellDemo/.DS_Store 3 | 4 | PickerCellDemo.xcodeproj/project.xcworkspace/xcuserdata/tom.xcuserdatad/UserInterfaceState (Mac Pro's conflicted copy 2011-11-10 (1)).xcuserstate 5 | 6 | PickerCellDemo.xcodeproj/xcuserdata/tom.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist 7 | 8 | PickerCellDemo.xcodeproj/project.xcworkspace/xcuserdata/tom.xcuserdatad/userinterfacestate (Mac Pro's conflicted copy 2011-11-10 (2)).xcuserstate 9 | 10 | PickerCellDemo.xcodeproj/project.xcworkspace/xcuserdata/tom.xcuserdatad/UserInterfaceState.xcuserstate 11 | 12 | PickerCellDemo.xcodeproj/project.xcworkspace/xcuserdata/tom.xcuserdatad/UserInterfaceState (sorlog's conflicted copy 2011-11-10 (4)).xcuserstate 13 | 14 | PickerCellDemo.xcodeproj/project.xcworkspace/xcuserdata/tom.xcuserdatad/UserInterfaceState (sorlog's conflicted copy 2011-11-10).xcuserstate 15 | 16 | PickerCellDemo.xcodeproj/project.xcworkspace/xcuserdata/tom.xcuserdatad/UserInterfaceState (sorlog's conflicted copy 2011-11-10 (3)).xcuserstate 17 | 18 | PickerCellDemo.xcodeproj/project.xcworkspace/xcuserdata/tom.xcuserdatad/UserInterfaceState (sorlog's conflicted copy 2011-11-10 (1)).xcuserstate 19 | 20 | PickerCellDemo.xcodeproj/project.xcworkspace/xcuserdata/tom.xcuserdatad/UserInterfaceState (Mac Pro's conflicted copy 2011-11-10).xcuserstate 21 | 22 | PickerCellDemo.xcodeproj/project.xcworkspace/xcuserdata/tom.xcuserdatad/UserInterfaceState (Mac Pro's conflicted copy 2011-11-10 (5)).xcuserstate 23 | 24 | PickerCellDemo.xcodeproj/project.xcworkspace/xcuserdata/tom.xcuserdatad/UserInterfaceState (Mac Pro's conflicted copy 2011-11-10 (4)).xcuserstate 25 | 26 | PickerCellDemo.xcodeproj/project.xcworkspace/xcuserdata/tom.xcuserdatad/UserInterfaceState (sorlog's conflicted copy 2011-11-10 (2)).xcuserstate 27 | 28 | PickerCellDemo.xcodeproj/project.xcworkspace/xcuserdata/tom.xcuserdatad/UserInterfaceState (Mac Pro's conflicted copy 2011-11-10 (3)).xcuserstate 29 | 30 | .DS_Store 31 | 32 | PickerCellDemo.xcodeproj/xcuserdata/josh.xcuserdatad* 33 | PickerCellDemo.xcodeproj/project.xcworkspace/xcuserdata* -------------------------------------------------------------------------------- /Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wannabegeek/PickerTableViewCell/2f7e9efac2c5ea23fbb298c78f7e049f566c0f2b/Default-568h@2x.png -------------------------------------------------------------------------------- /PickerCellDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4C17205D17A91E7A00D94131 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4C17205C17A91E7A00D94131 /* Default-568h@2x.png */; }; 11 | 4C17206017A91E9E00D94131 /* CustomUIPickerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C17205F17A91E9E00D94131 /* CustomUIPickerView.m */; }; 12 | E29FBE09146BAF830090B25A /* IntegerInputTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E29FBE08146BAF830090B25A /* IntegerInputTableViewCell.m */; }; 13 | E2CA1A62146B09E00070B8B9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2CA1A61146B09E00070B8B9 /* UIKit.framework */; }; 14 | E2CA1A64146B09E00070B8B9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2CA1A63146B09E00070B8B9 /* Foundation.framework */; }; 15 | E2CA1A66146B09E00070B8B9 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E2CA1A65146B09E00070B8B9 /* CoreGraphics.framework */; }; 16 | E2CA1A6C146B09E10070B8B9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = E2CA1A6A146B09E10070B8B9 /* InfoPlist.strings */; }; 17 | E2CA1A6E146B09E10070B8B9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E2CA1A6D146B09E10070B8B9 /* main.m */; }; 18 | E2CA1A72146B09E10070B8B9 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E2CA1A71146B09E10070B8B9 /* AppDelegate.m */; }; 19 | E2CA1A75146B09E10070B8B9 /* MainStoryboard_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2CA1A73146B09E10070B8B9 /* MainStoryboard_iPhone.storyboard */; }; 20 | E2CA1A78146B09E10070B8B9 /* MainStoryboard_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2CA1A76146B09E10070B8B9 /* MainStoryboard_iPad.storyboard */; }; 21 | E2CA1A7B146B09E10070B8B9 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E2CA1A7A146B09E10070B8B9 /* ViewController.m */; }; 22 | E2CA1A86146B0A550070B8B9 /* DateInputTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E2CA1A85146B0A550070B8B9 /* DateInputTableViewCell.m */; }; 23 | E2CA1A89146B0CC80070B8B9 /* StringInputTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E2CA1A88146B0CC80070B8B9 /* StringInputTableViewCell.m */; }; 24 | E2CA1A8C146B0DB00070B8B9 /* UIColor+Custom.m in Sources */ = {isa = PBXBuildFile; fileRef = E2CA1A8A146B0DB00070B8B9 /* UIColor+Custom.m */; }; 25 | E2CA1A97146C49870070B8B9 /* PickerInputTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E2CA1A96146C49870070B8B9 /* PickerInputTableViewCell.m */; }; 26 | E2CA1A9B146C4CD90070B8B9 /* SimplePickerInputTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E2CA1A9A146C4CD90070B8B9 /* SimplePickerInputTableViewCell.m */; }; 27 | /* End PBXBuildFile section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | 4C17205C17A91E7A00D94131 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 31 | 4C17205E17A91E9E00D94131 /* CustomUIPickerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomUIPickerView.h; sourceTree = ""; }; 32 | 4C17205F17A91E9E00D94131 /* CustomUIPickerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CustomUIPickerView.m; sourceTree = ""; }; 33 | E29FBE07146BAF830090B25A /* IntegerInputTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntegerInputTableViewCell.h; sourceTree = ""; }; 34 | E29FBE08146BAF830090B25A /* IntegerInputTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IntegerInputTableViewCell.m; sourceTree = ""; }; 35 | E2CA1A5D146B09E00070B8B9 /* PickerCellDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PickerCellDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 36 | E2CA1A61146B09E00070B8B9 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 37 | E2CA1A63146B09E00070B8B9 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 38 | E2CA1A65146B09E00070B8B9 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 39 | E2CA1A69146B09E00070B8B9 /* PickerCellDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "PickerCellDemo-Info.plist"; sourceTree = ""; }; 40 | E2CA1A6B146B09E10070B8B9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 41 | E2CA1A6D146B09E10070B8B9 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 42 | E2CA1A6F146B09E10070B8B9 /* PickerCellDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PickerCellDemo-Prefix.pch"; sourceTree = ""; }; 43 | E2CA1A70146B09E10070B8B9 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 44 | E2CA1A71146B09E10070B8B9 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 45 | E2CA1A74146B09E10070B8B9 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPhone.storyboard; sourceTree = ""; }; 46 | E2CA1A77146B09E10070B8B9 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPad.storyboard; sourceTree = ""; }; 47 | E2CA1A79146B09E10070B8B9 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 48 | E2CA1A7A146B09E10070B8B9 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 49 | E2CA1A84146B0A550070B8B9 /* DateInputTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DateInputTableViewCell.h; sourceTree = ""; }; 50 | E2CA1A85146B0A550070B8B9 /* DateInputTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DateInputTableViewCell.m; sourceTree = ""; }; 51 | E2CA1A87146B0CC70070B8B9 /* StringInputTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringInputTableViewCell.h; sourceTree = ""; }; 52 | E2CA1A88146B0CC80070B8B9 /* StringInputTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StringInputTableViewCell.m; sourceTree = ""; }; 53 | E2CA1A8A146B0DB00070B8B9 /* UIColor+Custom.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+Custom.m"; sourceTree = ""; }; 54 | E2CA1A8B146B0DB00070B8B9 /* UIColor+Custom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+Custom.h"; sourceTree = ""; }; 55 | E2CA1A95146C49870070B8B9 /* PickerInputTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PickerInputTableViewCell.h; sourceTree = ""; }; 56 | E2CA1A96146C49870070B8B9 /* PickerInputTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PickerInputTableViewCell.m; sourceTree = ""; }; 57 | E2CA1A99146C4CD90070B8B9 /* SimplePickerInputTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimplePickerInputTableViewCell.h; sourceTree = ""; }; 58 | E2CA1A9A146C4CD90070B8B9 /* SimplePickerInputTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimplePickerInputTableViewCell.m; sourceTree = ""; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | E2CA1A5A146B09E00070B8B9 /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | E2CA1A62146B09E00070B8B9 /* UIKit.framework in Frameworks */, 67 | E2CA1A64146B09E00070B8B9 /* Foundation.framework in Frameworks */, 68 | E2CA1A66146B09E00070B8B9 /* CoreGraphics.framework in Frameworks */, 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | /* End PBXFrameworksBuildPhase section */ 73 | 74 | /* Begin PBXGroup section */ 75 | E2CA1A52146B09E00070B8B9 = { 76 | isa = PBXGroup; 77 | children = ( 78 | 4C17205C17A91E7A00D94131 /* Default-568h@2x.png */, 79 | E2CA1A67146B09E00070B8B9 /* PickerCellDemo */, 80 | E2CA1A60146B09E00070B8B9 /* Frameworks */, 81 | E2CA1A5E146B09E00070B8B9 /* Products */, 82 | ); 83 | sourceTree = ""; 84 | }; 85 | E2CA1A5E146B09E00070B8B9 /* Products */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | E2CA1A5D146B09E00070B8B9 /* PickerCellDemo.app */, 89 | ); 90 | name = Products; 91 | sourceTree = ""; 92 | }; 93 | E2CA1A60146B09E00070B8B9 /* Frameworks */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | E2CA1A61146B09E00070B8B9 /* UIKit.framework */, 97 | E2CA1A63146B09E00070B8B9 /* Foundation.framework */, 98 | E2CA1A65146B09E00070B8B9 /* CoreGraphics.framework */, 99 | ); 100 | name = Frameworks; 101 | sourceTree = ""; 102 | }; 103 | E2CA1A67146B09E00070B8B9 /* PickerCellDemo */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 4C17205E17A91E9E00D94131 /* CustomUIPickerView.h */, 107 | 4C17205F17A91E9E00D94131 /* CustomUIPickerView.m */, 108 | E2CA1A70146B09E10070B8B9 /* AppDelegate.h */, 109 | E2CA1A71146B09E10070B8B9 /* AppDelegate.m */, 110 | E2CA1A73146B09E10070B8B9 /* MainStoryboard_iPhone.storyboard */, 111 | E2CA1A76146B09E10070B8B9 /* MainStoryboard_iPad.storyboard */, 112 | E2CA1A79146B09E10070B8B9 /* ViewController.h */, 113 | E2CA1A7A146B09E10070B8B9 /* ViewController.m */, 114 | E2CA1A84146B0A550070B8B9 /* DateInputTableViewCell.h */, 115 | E2CA1A85146B0A550070B8B9 /* DateInputTableViewCell.m */, 116 | E2CA1A87146B0CC70070B8B9 /* StringInputTableViewCell.h */, 117 | E2CA1A88146B0CC80070B8B9 /* StringInputTableViewCell.m */, 118 | E29FBE07146BAF830090B25A /* IntegerInputTableViewCell.h */, 119 | E29FBE08146BAF830090B25A /* IntegerInputTableViewCell.m */, 120 | E2CA1A95146C49870070B8B9 /* PickerInputTableViewCell.h */, 121 | E2CA1A96146C49870070B8B9 /* PickerInputTableViewCell.m */, 122 | E2CA1A99146C4CD90070B8B9 /* SimplePickerInputTableViewCell.h */, 123 | E2CA1A9A146C4CD90070B8B9 /* SimplePickerInputTableViewCell.m */, 124 | E2CA1A68146B09E00070B8B9 /* Supporting Files */, 125 | ); 126 | path = PickerCellDemo; 127 | sourceTree = ""; 128 | }; 129 | E2CA1A68146B09E00070B8B9 /* Supporting Files */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | E2CA1A69146B09E00070B8B9 /* PickerCellDemo-Info.plist */, 133 | E2CA1A6A146B09E10070B8B9 /* InfoPlist.strings */, 134 | E2CA1A6D146B09E10070B8B9 /* main.m */, 135 | E2CA1A6F146B09E10070B8B9 /* PickerCellDemo-Prefix.pch */, 136 | E2CA1A8A146B0DB00070B8B9 /* UIColor+Custom.m */, 137 | E2CA1A8B146B0DB00070B8B9 /* UIColor+Custom.h */, 138 | ); 139 | name = "Supporting Files"; 140 | sourceTree = ""; 141 | }; 142 | /* End PBXGroup section */ 143 | 144 | /* Begin PBXNativeTarget section */ 145 | E2CA1A5C146B09E00070B8B9 /* PickerCellDemo */ = { 146 | isa = PBXNativeTarget; 147 | buildConfigurationList = E2CA1A7E146B09E10070B8B9 /* Build configuration list for PBXNativeTarget "PickerCellDemo" */; 148 | buildPhases = ( 149 | E2CA1A59146B09E00070B8B9 /* Sources */, 150 | E2CA1A5A146B09E00070B8B9 /* Frameworks */, 151 | E2CA1A5B146B09E00070B8B9 /* Resources */, 152 | ); 153 | buildRules = ( 154 | ); 155 | dependencies = ( 156 | ); 157 | name = PickerCellDemo; 158 | productName = PickerCellDemo; 159 | productReference = E2CA1A5D146B09E00070B8B9 /* PickerCellDemo.app */; 160 | productType = "com.apple.product-type.application"; 161 | }; 162 | /* End PBXNativeTarget section */ 163 | 164 | /* Begin PBXProject section */ 165 | E2CA1A54146B09E00070B8B9 /* Project object */ = { 166 | isa = PBXProject; 167 | attributes = { 168 | LastUpgradeCheck = 0460; 169 | }; 170 | buildConfigurationList = E2CA1A57146B09E00070B8B9 /* Build configuration list for PBXProject "PickerCellDemo" */; 171 | compatibilityVersion = "Xcode 3.2"; 172 | developmentRegion = English; 173 | hasScannedForEncodings = 0; 174 | knownRegions = ( 175 | en, 176 | ); 177 | mainGroup = E2CA1A52146B09E00070B8B9; 178 | productRefGroup = E2CA1A5E146B09E00070B8B9 /* Products */; 179 | projectDirPath = ""; 180 | projectRoot = ""; 181 | targets = ( 182 | E2CA1A5C146B09E00070B8B9 /* PickerCellDemo */, 183 | ); 184 | }; 185 | /* End PBXProject section */ 186 | 187 | /* Begin PBXResourcesBuildPhase section */ 188 | E2CA1A5B146B09E00070B8B9 /* Resources */ = { 189 | isa = PBXResourcesBuildPhase; 190 | buildActionMask = 2147483647; 191 | files = ( 192 | E2CA1A6C146B09E10070B8B9 /* InfoPlist.strings in Resources */, 193 | E2CA1A75146B09E10070B8B9 /* MainStoryboard_iPhone.storyboard in Resources */, 194 | E2CA1A78146B09E10070B8B9 /* MainStoryboard_iPad.storyboard in Resources */, 195 | 4C17205D17A91E7A00D94131 /* Default-568h@2x.png in Resources */, 196 | ); 197 | runOnlyForDeploymentPostprocessing = 0; 198 | }; 199 | /* End PBXResourcesBuildPhase section */ 200 | 201 | /* Begin PBXSourcesBuildPhase section */ 202 | E2CA1A59146B09E00070B8B9 /* Sources */ = { 203 | isa = PBXSourcesBuildPhase; 204 | buildActionMask = 2147483647; 205 | files = ( 206 | E2CA1A6E146B09E10070B8B9 /* main.m in Sources */, 207 | E2CA1A72146B09E10070B8B9 /* AppDelegate.m in Sources */, 208 | E2CA1A7B146B09E10070B8B9 /* ViewController.m in Sources */, 209 | E2CA1A86146B0A550070B8B9 /* DateInputTableViewCell.m in Sources */, 210 | E2CA1A89146B0CC80070B8B9 /* StringInputTableViewCell.m in Sources */, 211 | E2CA1A8C146B0DB00070B8B9 /* UIColor+Custom.m in Sources */, 212 | E29FBE09146BAF830090B25A /* IntegerInputTableViewCell.m in Sources */, 213 | E2CA1A97146C49870070B8B9 /* PickerInputTableViewCell.m in Sources */, 214 | E2CA1A9B146C4CD90070B8B9 /* SimplePickerInputTableViewCell.m in Sources */, 215 | 4C17206017A91E9E00D94131 /* CustomUIPickerView.m in Sources */, 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | /* End PBXSourcesBuildPhase section */ 220 | 221 | /* Begin PBXVariantGroup section */ 222 | E2CA1A6A146B09E10070B8B9 /* InfoPlist.strings */ = { 223 | isa = PBXVariantGroup; 224 | children = ( 225 | E2CA1A6B146B09E10070B8B9 /* en */, 226 | ); 227 | name = InfoPlist.strings; 228 | sourceTree = ""; 229 | }; 230 | E2CA1A73146B09E10070B8B9 /* MainStoryboard_iPhone.storyboard */ = { 231 | isa = PBXVariantGroup; 232 | children = ( 233 | E2CA1A74146B09E10070B8B9 /* en */, 234 | ); 235 | name = MainStoryboard_iPhone.storyboard; 236 | sourceTree = ""; 237 | }; 238 | E2CA1A76146B09E10070B8B9 /* MainStoryboard_iPad.storyboard */ = { 239 | isa = PBXVariantGroup; 240 | children = ( 241 | E2CA1A77146B09E10070B8B9 /* en */, 242 | ); 243 | name = MainStoryboard_iPad.storyboard; 244 | sourceTree = ""; 245 | }; 246 | /* End PBXVariantGroup section */ 247 | 248 | /* Begin XCBuildConfiguration section */ 249 | E2CA1A7C146B09E10070B8B9 /* Debug */ = { 250 | isa = XCBuildConfiguration; 251 | buildSettings = { 252 | ALWAYS_SEARCH_USER_PATHS = NO; 253 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 254 | CLANG_ENABLE_OBJC_ARC = YES; 255 | CLANG_WARN_CONSTANT_CONVERSION = YES; 256 | CLANG_WARN_ENUM_CONVERSION = YES; 257 | CLANG_WARN_INT_CONVERSION = YES; 258 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 259 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 260 | COPY_PHASE_STRIP = NO; 261 | GCC_C_LANGUAGE_STANDARD = gnu99; 262 | GCC_DYNAMIC_NO_PIC = NO; 263 | GCC_OPTIMIZATION_LEVEL = 0; 264 | GCC_PREPROCESSOR_DEFINITIONS = ( 265 | "DEBUG=1", 266 | "$(inherited)", 267 | ); 268 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 269 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 270 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 271 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 272 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 273 | GCC_WARN_UNUSED_VARIABLE = YES; 274 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 275 | SDKROOT = iphoneos; 276 | TARGETED_DEVICE_FAMILY = "1,2"; 277 | }; 278 | name = Debug; 279 | }; 280 | E2CA1A7D146B09E10070B8B9 /* Release */ = { 281 | isa = XCBuildConfiguration; 282 | buildSettings = { 283 | ALWAYS_SEARCH_USER_PATHS = NO; 284 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 285 | CLANG_ENABLE_OBJC_ARC = YES; 286 | CLANG_WARN_CONSTANT_CONVERSION = YES; 287 | CLANG_WARN_ENUM_CONVERSION = YES; 288 | CLANG_WARN_INT_CONVERSION = YES; 289 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 290 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 291 | COPY_PHASE_STRIP = YES; 292 | GCC_C_LANGUAGE_STANDARD = gnu99; 293 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 294 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 295 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 296 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 297 | GCC_WARN_UNUSED_VARIABLE = YES; 298 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 299 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 300 | SDKROOT = iphoneos; 301 | TARGETED_DEVICE_FAMILY = "1,2"; 302 | VALIDATE_PRODUCT = YES; 303 | }; 304 | name = Release; 305 | }; 306 | E2CA1A7F146B09E10070B8B9 /* Debug */ = { 307 | isa = XCBuildConfiguration; 308 | buildSettings = { 309 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 310 | GCC_PREFIX_HEADER = "PickerCellDemo/PickerCellDemo-Prefix.pch"; 311 | INFOPLIST_FILE = "PickerCellDemo/PickerCellDemo-Info.plist"; 312 | PRODUCT_NAME = "$(TARGET_NAME)"; 313 | WRAPPER_EXTENSION = app; 314 | }; 315 | name = Debug; 316 | }; 317 | E2CA1A80146B09E10070B8B9 /* Release */ = { 318 | isa = XCBuildConfiguration; 319 | buildSettings = { 320 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 321 | GCC_PREFIX_HEADER = "PickerCellDemo/PickerCellDemo-Prefix.pch"; 322 | INFOPLIST_FILE = "PickerCellDemo/PickerCellDemo-Info.plist"; 323 | PRODUCT_NAME = "$(TARGET_NAME)"; 324 | WRAPPER_EXTENSION = app; 325 | }; 326 | name = Release; 327 | }; 328 | /* End XCBuildConfiguration section */ 329 | 330 | /* Begin XCConfigurationList section */ 331 | E2CA1A57146B09E00070B8B9 /* Build configuration list for PBXProject "PickerCellDemo" */ = { 332 | isa = XCConfigurationList; 333 | buildConfigurations = ( 334 | E2CA1A7C146B09E10070B8B9 /* Debug */, 335 | E2CA1A7D146B09E10070B8B9 /* Release */, 336 | ); 337 | defaultConfigurationIsVisible = 0; 338 | defaultConfigurationName = Release; 339 | }; 340 | E2CA1A7E146B09E10070B8B9 /* Build configuration list for PBXNativeTarget "PickerCellDemo" */ = { 341 | isa = XCConfigurationList; 342 | buildConfigurations = ( 343 | E2CA1A7F146B09E10070B8B9 /* Debug */, 344 | E2CA1A80146B09E10070B8B9 /* Release */, 345 | ); 346 | defaultConfigurationIsVisible = 0; 347 | defaultConfigurationName = Release; 348 | }; 349 | /* End XCConfigurationList section */ 350 | }; 351 | rootObject = E2CA1A54146B09E00070B8B9 /* Project object */; 352 | } 353 | -------------------------------------------------------------------------------- /PickerCellDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PickerCellDemo.xcodeproj/xcuserdata/michael.xcuserdatad/xcschemes/PickerCellDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 76 | 77 | 78 | 79 | 81 | 82 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /PickerCellDemo.xcodeproj/xcuserdata/michael.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | PickerCellDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | E2CA1A5C146B09E00070B8B9 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /PickerCellDemo.xcodeproj/xcuserdata/tom.xcuserdatad/xcschemes/PickerCellDemo.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | 14 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 49 | 50 | 56 | 57 | 58 | 59 | 60 | 61 | 67 | 68 | 74 | 75 | 76 | 77 | 79 | 80 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /PickerCellDemo.xcodeproj/xcuserdata/tom.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | PickerCellDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | E2CA1A5C146B09E00070B8B9 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /PickerCellDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // PickerCellDemo 4 | // 5 | // Created by Tom Fewster on 09/11/2011. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PickerCellDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // PickerCellDemo 4 | // 5 | // Created by Tom Fewster on 09/11/2011. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | @synthesize window = _window; 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | // Override point for customization after application launch. 18 | return YES; 19 | } 20 | 21 | - (void)applicationWillResignActive:(UIApplication *)application 22 | { 23 | /* 24 | 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. 25 | 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. 26 | */ 27 | } 28 | 29 | - (void)applicationDidEnterBackground:(UIApplication *)application 30 | { 31 | /* 32 | 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. 33 | If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 34 | */ 35 | } 36 | 37 | - (void)applicationWillEnterForeground:(UIApplication *)application 38 | { 39 | /* 40 | 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. 41 | */ 42 | } 43 | 44 | - (void)applicationDidBecomeActive:(UIApplication *)application 45 | { 46 | /* 47 | 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. 48 | */ 49 | } 50 | 51 | - (void)applicationWillTerminate:(UIApplication *)application 52 | { 53 | /* 54 | Called when the application is about to terminate. 55 | Save data if appropriate. 56 | See also applicationDidEnterBackground:. 57 | */ 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /PickerCellDemo/CustomUIPickerView.h: -------------------------------------------------------------------------------- 1 | // 2 | // CustomUIPickerView.h 3 | // PickerCellDemo 4 | // 5 | // Created by Michael on 7/30/13. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface CustomUIPickerView : UIPickerView 12 | 13 | @property (nonatomic) int currentRow; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PickerCellDemo/CustomUIPickerView.m: -------------------------------------------------------------------------------- 1 | // 2 | // CustomUIPickerView.m 3 | // PickerCellDemo 4 | // 5 | // Created by Michael on 7/30/13. 6 | // 7 | // 8 | 9 | #import "CustomUIPickerView.h" 10 | 11 | @implementation CustomUIPickerView 12 | 13 | @synthesize currentRow = _currentRow; 14 | 15 | - (id)initWithFrame:(CGRect)frame 16 | { 17 | self = [super initWithFrame:frame]; 18 | if (self) { 19 | // Initialization code 20 | } 21 | return self; 22 | } 23 | 24 | -(void)didMoveToSuperview{ 25 | [self selectRow:self.currentRow inComponent:0 animated:NO]; 26 | } 27 | 28 | /* 29 | // Only override drawRect: if you perform custom drawing. 30 | // An empty implementation adversely affects performance during animation. 31 | - (void)drawRect:(CGRect)rect 32 | { 33 | // Drawing code 34 | } 35 | */ 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /PickerCellDemo/DateInputTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // DateInputTableViewCell.h 3 | // ShootStudio 4 | // 5 | // Created by Tom Fewster on 18/10/2011. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class DateInputTableViewCell; 12 | 13 | @protocol DateInputTableViewCellDelegate 14 | @optional 15 | - (void)tableViewCell:(DateInputTableViewCell *)cell didEndEditingWithDate:(NSDate *)value; 16 | - (void)tableViewCell:(DateInputTableViewCell *)cell didEndEditingWithDuration:(NSTimeInterval)value; 17 | @end 18 | 19 | @interface DateInputTableViewCell : UITableViewCell { 20 | UIPopoverController *popoverController; 21 | UIToolbar *inputAccessoryView; 22 | } 23 | 24 | @property (nonatomic, strong) NSDate *dateValue; 25 | @property (nonatomic, assign) NSTimeInterval timerValue; 26 | @property (nonatomic, assign) UIDatePickerMode datePickerMode; 27 | @property (nonatomic, strong) NSDateFormatter *dateFormatter; 28 | @property (nonatomic, strong) UIDatePicker *datePicker; 29 | @property (weak) IBOutlet id delegate; 30 | 31 | - (void)setMaxDate:(NSDate *)max; 32 | - (void)setMinDate:(NSDate *)min; 33 | - (void)setMinuteInterval:(NSUInteger)value; 34 | - (NSString *)timerStringValue; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /PickerCellDemo/DateInputTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // DateInputTableViewCell.m 3 | // ShootStudio 4 | // 5 | // Created by Tom Fewster on 18/10/2011. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "DateInputTableViewCell.h" 10 | 11 | @implementation DateInputTableViewCell 12 | 13 | @synthesize delegate; 14 | @synthesize dateValue; 15 | @synthesize dateFormatter; 16 | @synthesize datePicker; 17 | @synthesize timerValue = _timerValue; 18 | 19 | - (void)initalizeInputView { 20 | dateValue = [NSDate date]; 21 | 22 | // Initialization code 23 | self.datePicker = [[UIDatePicker alloc] initWithFrame:CGRectZero]; 24 | [datePicker setDatePickerMode:UIDatePickerModeDate]; 25 | datePicker.date = self.dateValue; 26 | [datePicker addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged]; 27 | 28 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 29 | UIViewController *popoverContent = [[UIViewController alloc] init]; 30 | popoverContent.view = self.datePicker; 31 | popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent]; 32 | popoverController.delegate = self; 33 | } else { 34 | CGRect frame = self.inputView.frame; 35 | frame.size = [self.datePicker sizeThatFits:CGSizeZero]; 36 | self.inputView.frame = frame; 37 | self.datePicker.autoresizingMask = UIViewAutoresizingFlexibleHeight; 38 | } 39 | 40 | self.dateFormatter = [[NSDateFormatter alloc] init]; 41 | self.dateFormatter.timeStyle = NSDateFormatterNoStyle; 42 | self.dateFormatter.dateStyle = NSDateFormatterMediumStyle; 43 | 44 | if (self.datePicker.datePickerMode == UIDatePickerModeCountDownTimer) { 45 | self.detailTextLabel.text = [self timerStringValue]; 46 | } else { 47 | self.detailTextLabel.text = [self.dateFormatter stringFromDate:self.dateValue]; 48 | } 49 | } 50 | 51 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 52 | { 53 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 54 | if (self) { 55 | [self initalizeInputView]; 56 | } 57 | return self; 58 | } 59 | 60 | - (id)initWithCoder:(NSCoder *)aDecoder { 61 | self = [super initWithCoder:aDecoder]; 62 | if (self) { 63 | [self initalizeInputView]; 64 | } 65 | return self; 66 | } 67 | 68 | 69 | - (UIView *)inputView { 70 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 71 | return nil; 72 | } else { 73 | return self.datePicker; 74 | } 75 | } 76 | 77 | - (UIView *)inputAccessoryView { 78 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 79 | return nil; 80 | } else { 81 | if (!inputAccessoryView) { 82 | inputAccessoryView = [[UIToolbar alloc] init]; 83 | inputAccessoryView.barStyle = UIBarStyleBlackTranslucent; 84 | inputAccessoryView.autoresizingMask = UIViewAutoresizingFlexibleHeight; 85 | [inputAccessoryView sizeToFit]; 86 | CGRect frame = inputAccessoryView.frame; 87 | frame.size.height = 44.0f; 88 | inputAccessoryView.frame = frame; 89 | 90 | UIBarButtonItem *doneBtn =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done:)]; 91 | UIBarButtonItem *flexibleSpaceLeft = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; 92 | 93 | NSArray *array = [NSArray arrayWithObjects:flexibleSpaceLeft, doneBtn, nil]; 94 | [inputAccessoryView setItems:array]; 95 | } 96 | return inputAccessoryView; 97 | } 98 | } 99 | 100 | - (void)done:(id)sender { 101 | [self resignFirstResponder]; 102 | } 103 | 104 | - (BOOL)becomeFirstResponder { 105 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 106 | CGSize pickerSize = [self.datePicker sizeThatFits:CGSizeZero]; 107 | CGRect frame = self.datePicker.frame; 108 | frame.size = pickerSize; 109 | self.datePicker.frame = frame; 110 | popoverController.popoverContentSize = pickerSize; 111 | [popoverController presentPopoverFromRect:self.detailTextLabel.frame inView:self permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 112 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceDidRotate:) name:UIDeviceOrientationDidChangeNotification object:nil]; 113 | } else { 114 | // nothing to do 115 | } 116 | 117 | if (self.datePickerMode == UIDatePickerModeCountDownTimer) { 118 | self.datePicker.countDownDuration = self.timerValue; 119 | } else { 120 | self.datePicker.date = self.dateValue; 121 | } 122 | 123 | return [super becomeFirstResponder]; 124 | } 125 | 126 | - (BOOL)resignFirstResponder { 127 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 128 | [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; 129 | } else { 130 | // Nothing to do 131 | } 132 | UITableView *tableView; 133 | if ([self.superview class] != [UITableView class]) 134 | { 135 | tableView = (UITableView *)self.superview.superview; 136 | } 137 | else 138 | { 139 | tableView = (UITableView *)self.superview; 140 | } 141 | [tableView deselectRowAtIndexPath:[tableView indexPathForCell:self] animated:YES]; 142 | return [super resignFirstResponder]; 143 | } 144 | 145 | - (void)prepareForReuse { 146 | self.dateFormatter.timeStyle = NSDateFormatterNoStyle; 147 | self.dateFormatter.dateStyle = NSDateFormatterMediumStyle; 148 | self.datePicker.datePickerMode = UIDatePickerModeDate; 149 | self.datePicker.maximumDate = nil; 150 | self.datePicker.minimumDate = nil; 151 | } 152 | 153 | - (void)setDateValue:(NSDate *)value { 154 | dateValue = value; 155 | if (self.datePicker.datePickerMode == UIDatePickerModeCountDownTimer) { 156 | // self.detailTextLabel.text = [self timerStringValue]; 157 | } else { 158 | self.detailTextLabel.text = [self.dateFormatter stringFromDate:self.dateValue]; 159 | } 160 | } 161 | 162 | - (void)setDatePickerMode:(UIDatePickerMode)mode { 163 | self.datePicker.datePickerMode = mode; 164 | self.dateFormatter.dateStyle = (mode==UIDatePickerModeDate||mode==UIDatePickerModeDateAndTime)?NSDateFormatterMediumStyle:NSDateFormatterNoStyle; 165 | self.dateFormatter.timeStyle = (mode==UIDatePickerModeTime||mode==UIDatePickerModeDateAndTime)?NSDateFormatterShortStyle:NSDateFormatterNoStyle; 166 | if (self.datePicker.datePickerMode == UIDatePickerModeCountDownTimer) { 167 | // self.dateValue = nil; // Causes crash 168 | self.timerValue = 60.0; 169 | self.detailTextLabel.text = [self timerStringValue]; 170 | } else { 171 | self.dateValue = [NSDate date]; 172 | self.timerValue = 0; 173 | self.detailTextLabel.text = [self.dateFormatter stringFromDate:self.dateValue]; 174 | } 175 | } 176 | 177 | - (UIDatePickerMode)datePickerMode { 178 | return self.datePicker.datePickerMode; 179 | } 180 | 181 | - (void)setMaxDate:(NSDate *)max { 182 | self.datePicker.maximumDate = max; 183 | } 184 | 185 | - (void)setMinDate:(NSDate *)min { 186 | self.datePicker.minimumDate = min; 187 | } 188 | 189 | - (void)setMinuteInterval:(NSUInteger)value { 190 | #pragma warning "Check with Apple why this causes a crash" 191 | // [self.datePicker setMinuteInterval:value]; 192 | } 193 | 194 | - (void)dateChanged:(id)sender { 195 | self.dateValue = ((UIDatePicker *)sender).date; 196 | self.timerValue = ((UIDatePicker *)sender).countDownDuration; 197 | 198 | if (delegate && self.dateValue) { 199 | if (self.datePicker.datePickerMode == UIDatePickerModeCountDownTimer && [delegate respondsToSelector:@selector(tableViewCell:didEndEditingWithDuration:)]) { 200 | [delegate tableViewCell:self didEndEditingWithDuration:self.timerValue]; 201 | } else if ([delegate respondsToSelector:@selector(tableViewCell:didEndEditingWithDate:)]) { 202 | [delegate tableViewCell:self didEndEditingWithDate:self.dateValue]; 203 | } 204 | } 205 | } 206 | 207 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated 208 | { 209 | [super setSelected:selected animated:animated]; 210 | 211 | if (selected) { 212 | [self becomeFirstResponder]; 213 | } 214 | } 215 | 216 | - (void)deviceDidRotate:(NSNotification*)notification { 217 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 218 | // we should only get this call if the popover is visible 219 | [popoverController presentPopoverFromRect:self.detailTextLabel.frame inView:self permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 220 | } 221 | } 222 | 223 | - (NSTimeInterval)timerValue { 224 | return self.datePicker.countDownDuration; 225 | } 226 | 227 | - (void)setTimerValue:(NSTimeInterval)timerValue { 228 | if (self.datePicker.datePickerMode == UIDatePickerModeCountDownTimer) { 229 | datePicker.countDownDuration = timerValue; 230 | _timerValue = timerValue; 231 | 232 | self.detailTextLabel.text = [self timerStringValue]; 233 | } else { 234 | // self.detailTextLabel.text = [self.dateFormatter stringFromDate:self.dateValue]; 235 | } 236 | } 237 | 238 | - (NSString *)timerStringValue { 239 | NSTimeInterval time = self.timerValue; 240 | NSString *result = nil; 241 | 242 | if (time >= 3600.0) { 243 | result = [NSString stringWithFormat:@"%uhr, %umin ", (int)(time / 3600.0), (int)((time / 60.0) - (floor(time / 3600.0) * 60.0))]; 244 | } else if (time >= 60.0) { 245 | result = [NSString stringWithFormat:@"%umin ", (int)(time / 60.0)]; 246 | } else { 247 | result = [NSString stringWithFormat:@"%usec ", (int)time]; 248 | } // The padding at the end makes it impossible for the detail label to trim the text 249 | 250 | // NSLog(@"%@", result); 251 | return result; 252 | } 253 | 254 | #pragma mark - 255 | #pragma mark Respond to touch and become first responder. 256 | 257 | - (BOOL)canBecomeFirstResponder { 258 | return YES; 259 | } 260 | 261 | #pragma mark - 262 | #pragma mark UIPopoverControllerDelegate Protocol Methods 263 | 264 | - (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController { 265 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 266 | UITableView *tableView; 267 | if ([self.superview class] != [UITableView class]) 268 | { 269 | tableView = (UITableView *)self.superview.superview; 270 | } 271 | else 272 | { 273 | tableView = (UITableView *)self.superview; 274 | } 275 | [tableView deselectRowAtIndexPath:[tableView indexPathForCell:self] animated:YES]; 276 | [self resignFirstResponder]; 277 | } 278 | } 279 | 280 | @end 281 | -------------------------------------------------------------------------------- /PickerCellDemo/IntegerInputTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // IntegerInputTableViewCell.h 3 | // InputTest 4 | // 5 | // Created by Tom Fewster on 18/10/2011. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class IntegerInputTableViewCell; 12 | 13 | @protocol IntegerInputTableViewCellDelegate 14 | @optional 15 | - (void)tableViewCell:(IntegerInputTableViewCell *)cell didEndEditingWithInteger:(NSUInteger)value; 16 | @end 17 | 18 | @interface IntegerInputTableViewCell : UITableViewCell { 19 | NSUInteger numberValue; 20 | BOOL valueChanged; 21 | NSUInteger lowerLimit; 22 | NSUInteger upperLimit; 23 | 24 | UIToolbar *inputAccessoryView; 25 | UIEdgeInsets originalContentInsets; 26 | UIEdgeInsets originalScrollInsets; 27 | } 28 | 29 | @property (nonatomic, assign) NSUInteger numberValue; 30 | @property (nonatomic, assign) NSUInteger lowerLimit; 31 | @property (nonatomic, assign) NSUInteger upperLimit; 32 | @property (nonatomic, strong) NSNumberFormatter *numberFormatter; 33 | @property (weak) IBOutlet id delegate; 34 | 35 | @property(nonatomic) UITextAutocapitalizationType autocapitalizationType; 36 | @property(nonatomic) UITextAutocorrectionType autocorrectionType; 37 | @property(nonatomic) BOOL enablesReturnKeyAutomatically; 38 | @property(nonatomic) UIKeyboardAppearance keyboardAppearance; 39 | @property(nonatomic) UIKeyboardType keyboardType; 40 | @property(nonatomic) UIReturnKeyType returnKeyType; 41 | @property(nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry; 42 | @property(nonatomic) UITextSpellCheckingType spellCheckingType; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /PickerCellDemo/IntegerInputTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // IntegerInputTableViewCell.m 3 | // InputTest 4 | // 5 | // Created by Tom Fewster on 18/10/2011. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "IntegerInputTableViewCell.h" 10 | 11 | @implementation IntegerInputTableViewCell 12 | 13 | @synthesize numberValue; 14 | @synthesize numberFormatter; 15 | @synthesize delegate; 16 | @synthesize lowerLimit; 17 | @synthesize upperLimit; 18 | 19 | @synthesize autocapitalizationType; 20 | @synthesize autocorrectionType; 21 | @synthesize enablesReturnKeyAutomatically; 22 | @synthesize keyboardAppearance; 23 | @synthesize keyboardType; 24 | @synthesize returnKeyType; 25 | @synthesize secureTextEntry; 26 | @synthesize spellCheckingType; 27 | 28 | - (void)initalizeInputView { 29 | // Initialization code 30 | self.keyboardType = UIKeyboardTypeNumberPad; 31 | self.lowerLimit = 0; 32 | self.upperLimit = UINT32_MAX; 33 | 34 | if (!self.numberFormatter) { 35 | self.numberFormatter = [[NSNumberFormatter alloc] init]; 36 | self.numberFormatter.numberStyle = NSNumberFormatterNoStyle; 37 | self.numberFormatter.maximumFractionDigits = 0; 38 | } 39 | 40 | self.detailTextLabel.text = [self.numberFormatter stringFromNumber:[NSNumber numberWithInteger:self.numberValue]]; 41 | self.detailTextLabel.textColor = [UIColor darkTextColor]; 42 | self.selectionStyle = UITableViewCellSelectionStyleNone; 43 | } 44 | 45 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 46 | { 47 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 48 | if (self) { 49 | [self initalizeInputView]; 50 | } 51 | return self; 52 | } 53 | 54 | - (id)initWithCoder:(NSCoder *)aDecoder { 55 | self = [super initWithCoder:aDecoder]; 56 | if (self) { 57 | [self initalizeInputView]; 58 | } 59 | return self; 60 | } 61 | 62 | - (UIView *)inputAccessoryView { 63 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 64 | return nil; 65 | } else { 66 | if (!inputAccessoryView) { 67 | inputAccessoryView = [[UIToolbar alloc] init]; 68 | inputAccessoryView.barStyle = UIBarStyleBlackTranslucent; 69 | inputAccessoryView.autoresizingMask = UIViewAutoresizingFlexibleHeight; 70 | [inputAccessoryView sizeToFit]; 71 | CGRect frame = inputAccessoryView.frame; 72 | frame.size.height = 44.0f; 73 | inputAccessoryView.frame = frame; 74 | 75 | UIBarButtonItem *doneBtn =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done:)]; 76 | UIBarButtonItem *flexibleSpaceLeft = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; 77 | 78 | NSArray *array = [NSArray arrayWithObjects:flexibleSpaceLeft, doneBtn, nil]; 79 | [inputAccessoryView setItems:array]; 80 | } 81 | return inputAccessoryView; 82 | } 83 | } 84 | 85 | - (void)done:(id)sender { 86 | [self resignFirstResponder]; 87 | } 88 | 89 | - (void)prepareForReuse { 90 | self.lowerLimit = 0; 91 | self.upperLimit = UINT32_MAX; 92 | } 93 | 94 | - (BOOL)resignFirstResponder { 95 | if (valueChanged && delegate && [delegate respondsToSelector:@selector(tableViewCell:didEndEditingWithInteger:)]) { 96 | [delegate tableViewCell:self didEndEditingWithInteger:self.numberValue]; 97 | } 98 | UITableView *tableView = nil; 99 | if ([self.superview isKindOfClass:[UITableView class]]) { 100 | tableView = (UITableView *)self.superview; 101 | } else if ([self.superview.superview isKindOfClass:[UITableView class]]) { 102 | tableView = (UITableView *)self.superview.superview; 103 | } 104 | [tableView deselectRowAtIndexPath:[tableView indexPathForCell:self] animated:YES]; 105 | return [super resignFirstResponder]; 106 | } 107 | 108 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated 109 | { 110 | [super setSelected:selected animated:animated]; 111 | if (selected) { 112 | [self becomeFirstResponder]; 113 | self.detailTextLabel.textColor = self.tintColor; 114 | } else { 115 | self.detailTextLabel.textColor = [UIColor darkTextColor]; 116 | } 117 | } 118 | 119 | - (void)setNumberValue:(NSUInteger)value { 120 | numberValue = value; 121 | valueChanged = NO; 122 | self.detailTextLabel.text = [self.numberFormatter stringFromNumber:[NSNumber numberWithInteger:self.numberValue]]; 123 | } 124 | 125 | #pragma mark - 126 | #pragma mark Respond to touch and become first responder. 127 | 128 | - (BOOL)canBecomeFirstResponder { 129 | return YES; 130 | } 131 | 132 | #pragma mark - 133 | #pragma mark UIKeyInput Protocol Methods 134 | 135 | - (BOOL)hasText { 136 | return (self.numberValue > 10); 137 | } 138 | 139 | - (void)insertText:(NSString *)theText { 140 | 141 | // make sure we receioved an integer (on the iPad a user chan change the keybord style) 142 | NSScanner *sc = [NSScanner scannerWithString:theText]; 143 | if ([sc scanInteger:NULL]) { 144 | if ([sc isAtEnd]) { 145 | NSUInteger addedValues = [theText integerValue]; 146 | 147 | self.numberValue *= (10 * theText.length); 148 | self.numberValue += addedValues; 149 | if (self.numberValue < self.lowerLimit) { 150 | self.numberValue = self.lowerLimit; 151 | } else if (self.numberValue > self.upperLimit) { 152 | self.numberValue = self.upperLimit; 153 | } 154 | self.detailTextLabel.text = [self.numberFormatter stringFromNumber:[NSNumber numberWithInteger:self.numberValue]]; 155 | valueChanged = YES; 156 | } 157 | } 158 | } 159 | 160 | - (void)deleteBackward { 161 | self.numberValue = self.numberValue / 10; 162 | if (self.numberValue < self.lowerLimit) { 163 | self.numberValue = self.lowerLimit; 164 | } else if (self.numberValue > self.upperLimit) { 165 | self.numberValue = self.upperLimit; 166 | } 167 | self.detailTextLabel.text = [self.numberFormatter stringFromNumber:[NSNumber numberWithInteger:self.numberValue]]; 168 | valueChanged = YES; 169 | } 170 | 171 | @end 172 | -------------------------------------------------------------------------------- /PickerCellDemo/PickerCellDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFiles 12 | 13 | CFBundleIdentifier 14 | tomfewster.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | UIMainStoryboardFile 30 | MainStoryboard_iPhone 31 | UIMainStoryboardFile~ipad 32 | MainStoryboard_iPad 33 | UIRequiredDeviceCapabilities 34 | 35 | armv7 36 | 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationLandscapeLeft 41 | UIInterfaceOrientationLandscapeRight 42 | UIInterfaceOrientationPortraitUpsideDown 43 | 44 | UISupportedInterfaceOrientations~ipad 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationPortraitUpsideDown 48 | UIInterfaceOrientationLandscapeLeft 49 | UIInterfaceOrientationLandscapeRight 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /PickerCellDemo/PickerCellDemo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'PickerCellDemo' target in the 'PickerCellDemo' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_5_0 8 | #warning "This project uses features only available in iOS SDK 5.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | 16 | #import "UIColor+Custom.h" -------------------------------------------------------------------------------- /PickerCellDemo/PickerInputTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // ShootStatusInputTableViewCell.h 3 | // ShootStudio 4 | // 5 | // Created by Tom Fewster on 18/10/2011. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class PickerInputTableViewCell; 12 | 13 | @interface PickerInputTableViewCell : UITableViewCell { 14 | // For iPad, the view controller which will contain the popover displayed 15 | UIViewController *popoverViewController; 16 | 17 | // For iPhone 18 | UIToolbar *inputAccessoryView; 19 | } 20 | 21 | @property (nonatomic, strong) CustomUIPickerView *picker; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /PickerCellDemo/PickerInputTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // PickerInputTableViewCell.m 3 | // ShootStudio 4 | // 5 | // Created by Tom Fewster on 18/10/2011. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "PickerInputTableViewCell.h" 10 | 11 | @implementation PickerInputTableViewCell 12 | 13 | static const float kAccessoryViewHeight = 44.0; 14 | 15 | @synthesize picker; 16 | 17 | - (void)initalizeInputView { 18 | self.picker = [[UIPickerView alloc] initWithFrame:CGRectZero]; 19 | self.picker.showsSelectionIndicator = YES; 20 | self.picker.autoresizingMask = UIViewAutoresizingFlexibleHeight; 21 | self.detailTextLabel.textColor = [UIColor darkTextColor]; 22 | self.selectionStyle = UITableViewCellSelectionStyleNone; 23 | 24 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 25 | 26 | // Setup the popover's view controller 27 | popoverViewController = [[UIViewController alloc] init]; 28 | popoverViewController.view = self.picker; 29 | popoverViewController.modalPresentationStyle = UIModalPresentationPopover; 30 | 31 | // Setup the delegate for UIPopoverPresentationControllerDelegate to ensure the following method 32 | // to be called which will ensure that the popover is always displayed halfway across the width 33 | // of the table view cell: 34 | // - (void)popoverPresentationController:(UIPopoverPresentationController *)popoverPresentationController 35 | // willRepositionPopoverToRect:(inout CGRect *)rect 36 | // inView:(inout UIView **)view 37 | popoverViewController.popoverPresentationController.delegate = self; 38 | } 39 | } 40 | 41 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 42 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 43 | 44 | if (self) { 45 | [self initalizeInputView]; 46 | } 47 | 48 | return self; 49 | } 50 | 51 | - (id)initWithCoder:(NSCoder *)aDecoder { 52 | self = [super initWithCoder:aDecoder]; 53 | 54 | if (self) { 55 | [self initalizeInputView]; 56 | } 57 | 58 | return self; 59 | } 60 | 61 | - (UIView *)inputView { 62 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 63 | return nil; 64 | } else { 65 | return self.picker; 66 | } 67 | } 68 | 69 | - (UIView *)inputAccessoryView { 70 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 71 | return nil; 72 | } else { 73 | if (!inputAccessoryView) { 74 | inputAccessoryView = [[UIToolbar alloc] init]; 75 | inputAccessoryView.barStyle = UIBarStyleBlackTranslucent; 76 | inputAccessoryView.autoresizingMask = UIViewAutoresizingFlexibleHeight; 77 | [inputAccessoryView sizeToFit]; 78 | CGRect frame = inputAccessoryView.frame; 79 | frame.size.height = kAccessoryViewHeight; 80 | inputAccessoryView.frame = frame; 81 | 82 | UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done:)]; 83 | UIBarButtonItem *flexibleSpaceLeft = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; 84 | 85 | NSArray *array = [NSArray arrayWithObjects:flexibleSpaceLeft, doneBtn, nil]; 86 | [inputAccessoryView setItems:array]; 87 | } 88 | 89 | return inputAccessoryView; 90 | } 91 | } 92 | 93 | - (void)done:(id)sender { 94 | [self resignFirstResponder]; 95 | } 96 | 97 | - (BOOL)becomeFirstResponder { 98 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceDidRotate:) name:UIDeviceOrientationDidChangeNotification object:nil]; 99 | 100 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 101 | [self displayPopover]; 102 | 103 | // Resign the current first responder 104 | for (UIView *subview in self.superview.subviews) { 105 | if ([subview isFirstResponder]) { 106 | [subview resignFirstResponder]; 107 | } 108 | } 109 | 110 | return NO; 111 | } else { 112 | [self.picker setNeedsLayout]; 113 | } 114 | 115 | return [super becomeFirstResponder]; 116 | } 117 | 118 | - (BOOL)resignFirstResponder { 119 | [[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; 120 | UITableView *tableView = nil; 121 | if ([self.superview isKindOfClass:[UITableView class]]) { 122 | tableView = (UITableView *)self.superview; 123 | } else if ([self.superview.superview isKindOfClass:[UITableView class]]) { 124 | tableView = (UITableView *)self.superview.superview; 125 | } 126 | [tableView deselectRowAtIndexPath:[tableView indexPathForCell:self] animated:YES]; 127 | return [super resignFirstResponder]; 128 | } 129 | 130 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 131 | // To handle duplicate calls to this method which appear to happen when selecting a table view cell on iPad. 132 | // https://stackoverflow.com/questions/5401226/uitableviewcell-selector-setselectedanimated-gets-called-many-times 133 | // 134 | // The resulting two calls to [self becomeFirstResponder] cause an app crash as the code attempts to draw two popovers 135 | if (self.selected == selected) { 136 | return; 137 | } 138 | 139 | [super setSelected:selected animated:animated]; 140 | 141 | if (selected) { 142 | [self becomeFirstResponder]; 143 | self.detailTextLabel.textColor = self.tintColor; 144 | } else { 145 | self.detailTextLabel.textColor = [UIColor darkTextColor]; 146 | } 147 | } 148 | 149 | - (void)deviceDidRotate:(NSNotification *)notification { 150 | 151 | 152 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 153 | // No additional logic needed as UIKit will redraw popover and the following method is used to ensure proper location 154 | // - (void)popoverPresentationController:(UIPopoverPresentationController *)popoverPresentationController 155 | // willRepositionPopoverToRect:(inout CGRect *)rect 156 | // inView:(inout UIView **)view 157 | } else { 158 | [self.picker setNeedsLayout]; 159 | } 160 | } 161 | 162 | - (void)displayPopover { 163 | CGSize pickerSize = [self.picker sizeThatFits:CGSizeZero]; 164 | 165 | popoverViewController.preferredContentSize = pickerSize; 166 | 167 | UITableView *tableView = [self findTableViewParent]; 168 | 169 | UITableViewController *tableViewController = (UITableViewController *)tableView.dataSource; 170 | 171 | [tableViewController presentViewController:popoverViewController animated:YES completion:nil]; 172 | 173 | // Get the popover presentation controller and configure it. 174 | UIPopoverPresentationController *presentationController = [popoverViewController popoverPresentationController]; 175 | presentationController.sourceView = self; 176 | 177 | // Position the popover to be halfway across the table view cell 178 | presentationController.sourceRect = CGRectMake(self.frame.size.width / 2, self.frame.size.height, 0, 0); 179 | } 180 | 181 | #pragma mark - 182 | #pragma mark UIPopoverPresentationControllerDelegate Protocol Methods 183 | 184 | - (void)popoverPresentationController:(UIPopoverPresentationController *)popoverPresentationController 185 | willRepositionPopoverToRect:(inout CGRect *)rect 186 | inView:(inout UIView **)view { 187 | 188 | // Reposition the popover to be halfway across the table view cell 189 | *rect = CGRectMake(self.frame.size.width / 2, self.frame.size.height, 0, 0); 190 | } 191 | 192 | // Not sure why this is needed. App appears to works correctly w/o it 193 | - (void)popoverPresentationControllerDidDismissPopover:(UIPopoverPresentationController *)popoverPresentationController { 194 | // Code that the GitHub Repository did not use my solution in the below find and used the commented out code 195 | UITableView *tableView = [self findTableViewParent]; 196 | /* 197 | UITableView *tableView = nil; 198 | if ([self.superview isKindOfClass:[UITableView class]]) { 199 | tableView = (UITableView *)self.superview; 200 | } else if ([self.superview.superview isKindOfClass:[UITableView class]]) { 201 | tableView = (UITableView *)self.superview.superview; 202 | } 203 | */ 204 | [tableView deselectRowAtIndexPath:[tableView indexPathForCell:self] animated:YES]; 205 | [self resignFirstResponder]; 206 | } 207 | 208 | #pragma mark - 209 | #pragma mark Respond to touch and become first responder. 210 | 211 | - (BOOL)canBecomeFirstResponder { 212 | return YES; 213 | } 214 | 215 | #pragma mark - 216 | #pragma mark UIKeyInput Protocol Methods 217 | 218 | - (BOOL)hasText { 219 | return YES; 220 | } 221 | 222 | - (void)insertText:(NSString *)theText { 223 | } 224 | 225 | - (void)deleteBackward { 226 | } 227 | 228 | @end 229 | -------------------------------------------------------------------------------- /PickerCellDemo/SimplePickerInputTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // SimplePickerInputTableViewCell.h 3 | // PickerCellDemo 4 | // 5 | // Created by Tom Fewster on 10/11/2011. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "PickerInputTableViewCell.h" 10 | 11 | @class SimplePickerInputTableViewCell; 12 | 13 | @protocol SimplePickerInputTableViewCellDelegate 14 | @optional 15 | - (void)tableViewCell:(SimplePickerInputTableViewCell *)cell didEndEditingWithValue:(NSString *)value; 16 | @end 17 | 18 | @interface SimplePickerInputTableViewCell : PickerInputTableViewCell { 19 | NSString *value; 20 | } 21 | 22 | @property (nonatomic, strong) NSString *value; 23 | @property (nonatomic, strong) NSArray *values; 24 | @property (weak) IBOutlet id delegate; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /PickerCellDemo/SimplePickerInputTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // SimplePickerInputTableViewCell.m 3 | // PickerCellDemo 4 | // 5 | // Created by Tom Fewster on 10/11/2011. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "SimplePickerInputTableViewCell.h" 10 | 11 | @implementation SimplePickerInputTableViewCell 12 | 13 | @synthesize delegate; 14 | // TODO- Recommend that this class is modified to attempt to have it not remember the state of the spinner selection. This information should be available from self.detailTextLabel.text. 15 | @synthesize value = _value; 16 | @synthesize values = _values; 17 | 18 | -(void)setValues:(NSArray *)newValues 19 | { 20 | _values = [newValues copy]; 21 | } 22 | 23 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 24 | { 25 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 26 | if (self) { 27 | [self initializeCommonElements]; 28 | } 29 | return self; 30 | } 31 | 32 | - (id)initWithCoder:(NSCoder *)aDecoder { 33 | self = [super initWithCoder:aDecoder]; 34 | if (self) { 35 | [self initializeCommonElements]; 36 | } 37 | return self; 38 | } 39 | 40 | - (void)initializeCommonElements { 41 | // Initialization code 42 | self.picker.delegate = self; 43 | self.picker.dataSource = self; 44 | 45 | // Default Values 46 | // TODO force user to pass in values in initialization method 47 | self.values = [NSArray arrayWithObjects:@"Value 1", @"Value 2", @"Value 3", @"Value 4", @"Value 5", nil]; 48 | 49 | } 50 | 51 | - (void)setValue:(NSString *)v { 52 | _value = v; 53 | self.detailTextLabel.text = _value; 54 | [self.picker selectRow:[self.values indexOfObject:_value] inComponent:0 animated:YES]; 55 | 56 | // Ensure the Picker can remember the last value selected even if the picker was rolling when closed 57 | int selectedRow = [self.values indexOfObject:_value]; 58 | [self.picker setCurrentRow:selectedRow]; 59 | } 60 | 61 | #pragma mark - 62 | #pragma mark UIPickerViewDataSource 63 | 64 | - (NSInteger)numberOfComponentsInPickerView:(CustomUIPickerView *)pickerView { 65 | return 1; 66 | } 67 | 68 | - (NSInteger)pickerView:(CustomUIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { 69 | return [self.values count]; 70 | } 71 | 72 | #pragma mark - 73 | #pragma mark UIPickerViewDelegate 74 | 75 | - (NSString *)pickerView:(CustomUIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { 76 | return [self.values objectAtIndex:row]; 77 | } 78 | 79 | - (CGFloat)pickerView:(CustomUIPickerView *)pickerView rowHeightForComponent:(NSInteger)component { 80 | return 44.0f; 81 | } 82 | 83 | - (CGFloat)pickerView:(CustomUIPickerView *)pickerView widthForComponent:(NSInteger)component { 84 | return 300.0f; //pickerView.bounds.size.width - 20.0f; 85 | } 86 | 87 | - (void)pickerView:(CustomUIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { 88 | self.value = [self.values objectAtIndex:row]; 89 | 90 | if (delegate && [delegate respondsToSelector:@selector(tableViewCell:didEndEditingWithValue:)]) { 91 | [delegate tableViewCell:self didEndEditingWithValue:self.value]; 92 | } 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /PickerCellDemo/StringInputTableViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // StringInputTableViewCell.h 3 | // ShootStudio 4 | // 5 | // Created by Tom Fewster on 19/10/2011. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class StringInputTableViewCell; 12 | 13 | @protocol StringInputTableViewCellDelegate 14 | @optional 15 | - (void)tableViewCell:(StringInputTableViewCell *)cell didEndEditingWithString:(NSString *)value; 16 | @end 17 | 18 | 19 | @interface StringInputTableViewCell : UITableViewCell { 20 | UITextField *textField; 21 | } 22 | 23 | @property (nonatomic, strong) NSString *stringValue; 24 | @property (nonatomic, strong) UITextField *textField; 25 | @property (weak) IBOutlet id delegate; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /PickerCellDemo/StringInputTableViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // StringInputTableViewCell.m 3 | // ShootStudio 4 | // 5 | // Created by Tom Fewster on 19/10/2011. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "StringInputTableViewCell.h" 10 | 11 | @implementation StringInputTableViewCell 12 | 13 | @synthesize delegate; 14 | @synthesize stringValue; 15 | @synthesize textField; 16 | 17 | - (void)initalizeInputView { 18 | // Initialization code 19 | self.selectionStyle = UITableViewCellSelectionStyleNone; 20 | self.textField = [[UITextField alloc] initWithFrame:CGRectZero]; 21 | self.textField.autocorrectionType = UITextAutocorrectionTypeDefault; 22 | self.textField.autocapitalizationType = UITextAutocapitalizationTypeWords; 23 | self.textField.textAlignment = NSTextAlignmentRight; 24 | self.textField.textColor = [UIColor darkTextColor]; 25 | self.textField.font = [UIFont systemFontOfSize:17.0f]; 26 | self.textField.clearButtonMode = UITextFieldViewModeNever; 27 | self.textField.autoresizingMask = UIViewAutoresizingFlexibleWidth; 28 | [self addSubview:self.textField]; 29 | 30 | self.accessoryType = UITableViewCellAccessoryNone; 31 | 32 | self.textField.delegate = self; 33 | } 34 | 35 | - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier 36 | { 37 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 38 | if (self) { 39 | [self initalizeInputView]; 40 | } 41 | return self; 42 | } 43 | 44 | - (id)initWithCoder:(NSCoder *)aDecoder { 45 | self = [super initWithCoder:aDecoder]; 46 | if (self) { 47 | [self initalizeInputView]; 48 | } 49 | return self; 50 | } 51 | 52 | - (void)setSelected:(BOOL)selected { 53 | [super setSelected:selected]; 54 | if (selected) { 55 | [self.textField becomeFirstResponder]; 56 | } 57 | } 58 | 59 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 60 | [super setSelected:selected animated:animated]; 61 | if (selected) { 62 | [self.textField becomeFirstResponder]; 63 | } 64 | } 65 | 66 | - (void)setStringValue:(NSString *)value { 67 | self.textField.text = value; 68 | } 69 | 70 | - (NSString *)stringValue { 71 | return self.textField.text; 72 | } 73 | 74 | - (BOOL)textFieldShouldReturn:(UITextField *)textField { 75 | [self.textField resignFirstResponder]; 76 | return YES; 77 | } 78 | 79 | - (void)textFieldDidEndEditing:(UITextField *)textField { 80 | if (delegate && [delegate respondsToSelector:@selector(tableViewCell:didEndEditingWithString:)]) { 81 | [delegate tableViewCell:self didEndEditingWithString:self.stringValue]; 82 | } 83 | UITableView *tableView = nil; 84 | if ([self.superview isKindOfClass:[UITableView class]]) { 85 | tableView = (UITableView *)self.superview; 86 | } else if ([self.superview.superview isKindOfClass:[UITableView class]]) { 87 | tableView = (UITableView *)self.superview.superview; 88 | } 89 | [tableView deselectRowAtIndexPath:[tableView indexPathForCell:self] animated:YES]; 90 | } 91 | 92 | - (void)layoutSubviews { 93 | [super layoutSubviews]; 94 | CGRect editFrame = CGRectInset(self.contentView.frame, 10, 10); 95 | 96 | if (self.textLabel.text && [self.textLabel.text length] != 0) { 97 | CGSize textSize = [self.textLabel sizeThatFits:CGSizeZero]; 98 | editFrame.origin.x += textSize.width + 10; 99 | editFrame.size.width -= textSize.width + 10; 100 | self.textField.textAlignment = NSTextAlignmentRight; 101 | } else { 102 | self.textField.textAlignment = NSTextAlignmentLeft; 103 | } 104 | 105 | self.textField.frame = editFrame; 106 | } 107 | 108 | @end 109 | -------------------------------------------------------------------------------- /PickerCellDemo/UIColor+Custom.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+Custom.h 3 | // ShootStudio 4 | // 5 | // Created by Tom Fewster on 30/09/2011. 6 | // Copyright (c) 2011 Tom Fewster. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIColor (Custom) 12 | 13 | + (UIColor *)blueTextColor; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /PickerCellDemo/UIColor+Custom.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+Custom.h 3 | // ShootStudio 4 | // 5 | // Created by Tom Fewster on 30/09/2011. 6 | // Copyright (c) 2011 Tom Fewster. All rights reserved. 7 | // 8 | 9 | #import "UIColor+Custom.h" 10 | 11 | @implementation UIColor (Custom) 12 | 13 | + (UIColor *)blueTextColor { 14 | return [UIColor colorWithRed:0.243 green:0.306 blue:0.435 alpha:1.0]; 15 | } 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /PickerCellDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // PickerCellDemo 4 | // 5 | // Created by Tom Fewster on 09/11/2011. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "DateInputTableViewCell.h" 11 | #import "StringInputTableViewCell.h" 12 | #import "IntegerInputTableViewCell.h" 13 | #import "SimplePickerInputTableViewCell.h" 14 | 15 | @interface ViewController : UITableViewController 16 | 17 | @property (weak) IBOutlet DateInputTableViewCell *date1; 18 | @property (weak) IBOutlet DateInputTableViewCell *date2; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /PickerCellDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // PickerCellDemo 4 | // 5 | // Created by Tom Fewster on 09/11/2011. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | 11 | @implementation ViewController 12 | 13 | @synthesize date1; 14 | @synthesize date2; 15 | 16 | - (void)didReceiveMemoryWarning 17 | { 18 | [super didReceiveMemoryWarning]; 19 | // Release any cached data, images, etc that aren't in use. 20 | } 21 | 22 | #pragma mark - View lifecycle 23 | 24 | - (void)viewDidLoad 25 | { 26 | [super viewDidLoad]; 27 | // Do any additional setup after loading the view, typically from a nib. 28 | } 29 | 30 | - (void)viewDidUnload 31 | { 32 | [super viewDidUnload]; 33 | // Release any retained subviews of the main view. 34 | // e.g. self.myOutlet = nil; 35 | } 36 | 37 | - (void)viewWillAppear:(BOOL)animated 38 | { 39 | [super viewWillAppear:animated]; 40 | } 41 | 42 | - (void)viewDidAppear:(BOOL)animated 43 | { 44 | [super viewDidAppear:animated]; 45 | } 46 | 47 | - (void)viewWillDisappear:(BOOL)animated 48 | { 49 | [super viewWillDisappear:animated]; 50 | } 51 | 52 | - (void)viewDidDisappear:(BOOL)animated 53 | { 54 | [super viewDidDisappear:animated]; 55 | } 56 | 57 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 58 | { 59 | return YES; 60 | } 61 | 62 | - (void)tableViewCell:(DateInputTableViewCell *)cell didEndEditingWithDate:(NSDate *)value { 63 | NSLog(@"%@ date changed to: %@", cell.textLabel.text, value); 64 | } 65 | 66 | - (void)tableViewCell:(IntegerInputTableViewCell *)cell didEndEditingWithInteger:(NSUInteger)value { 67 | NSLog(@"%@ number changed to: %i", cell.textLabel.text, value); 68 | } 69 | 70 | - (void)tableViewCell:(StringInputTableViewCell *)cell didEndEditingWithString:(NSString *)value { 71 | NSLog(@"%@ string changed to: '%@'", cell.textLabel.text, value); 72 | } 73 | 74 | - (void)tableViewCell:(SimplePickerInputTableViewCell *)cell didEndEditingWithValue:(NSString *)value { 75 | NSLog(@"%@ changed to: %@", cell.textLabel.text, value); 76 | } 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /PickerCellDemo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /PickerCellDemo/en.lproj/MainStoryboard_iPad.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 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 55 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 88 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 117 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 150 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 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 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | -------------------------------------------------------------------------------- /PickerCellDemo/en.lproj/MainStoryboard_iPhone.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 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 55 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 88 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 117 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 150 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 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 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | -------------------------------------------------------------------------------- /PickerCellDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PickerCellDemo 4 | // 5 | // Created by Tom Fewster on 09/11/2011. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wannabegeek/PickerTableViewCell/2f7e9efac2c5ea23fbb298c78f7e049f566c0f2b/README --------------------------------------------------------------------------------