├── .gitignore ├── AUTHORS ├── ActionSheetPicker-Info.plist ├── ActionSheetPicker.podspec ├── ActionSheetPicker.xcodeproj └── project.pbxproj ├── ActionSheetPicker_Prefix.pch ├── CHANGELOG.md ├── Example ├── ActionSheetPickerViewController-iPad.xib ├── ActionSheetPickerViewController.xib ├── Classes │ ├── ActionSheetPicker.h │ ├── ActionSheetPickerAppDelegate.h │ ├── ActionSheetPickerAppDelegate.m │ ├── ActionSheetPickerCustomPickerDelegate.h │ ├── ActionSheetPickerCustomPickerDelegate.m │ ├── ActionSheetPickerViewController.h │ ├── ActionSheetPickerViewController.m │ ├── NSDate+TCUtils.h │ └── NSDate+TCUtils.m ├── Default-568h@2x.png ├── MainWindow.xib ├── iPad │ └── MainWindow-iPad.xib └── main.m ├── LICENSE ├── Pickers ├── AbstractActionSheetPicker.h ├── AbstractActionSheetPicker.m ├── ActionSheetCustomPicker.h ├── ActionSheetCustomPicker.m ├── ActionSheetCustomPickerDelegate.h ├── ActionSheetDatePicker.h ├── ActionSheetDatePicker.m ├── ActionSheetDistancePicker.h ├── ActionSheetDistancePicker.m ├── ActionSheetStringPicker.h ├── ActionSheetStringPicker.m ├── DistancePickerView.h └── DistancePickerView.m ├── README.md └── Screenshots ├── date.png ├── distance.png ├── ipad.png └── string.png /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | build/* 3 | *.pbxuser 4 | !default.pbxuser 5 | *.mode1v3 6 | !default.mode1v3 7 | *.mode2v3 8 | !default.mode2v3 9 | *.perspectivev3 10 | !default.perspectivev3 11 | *.xcworkspace 12 | !default.xcworkspace 13 | xcuserdata 14 | profile 15 | *.moved-aside 16 | ._* 17 | */build/* 18 | .DS_Store 19 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | ActionSheetPicker Contributors 2 | ================ 3 | 4 | 5 | Name github address email address twitter 6 | 7 | Original author and maintainer 8 | ------------------------- 9 | Tim Cinel github.com/sickanimations email@timcinel.com @TimCinel 10 | 11 | Contributors 12 | ------------ 13 | Filote Stefan github.com/sfilo 14 | Brett Gibson github.com/brettg 15 | John Garland github.com/johnnyg (iPad!) 16 | Mark van den Broek github.com/heyhoo 17 | Evan Cordell github.com/ecordell 18 | Greg Combs github.com/grgcombs (Refactor!) 19 | Hari Karam Singh github.com/Club15CC (ARC, CustomPicker) 20 | 21 | ActionSheetPicker exists because of these contributors, remember to thank them :) 22 | -------------------------------------------------------------------------------- /ActionSheetPicker-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | NSMainNibFile~ipad 30 | MainWindow-iPad 31 | UISupportedInterfaceOrientations 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /ActionSheetPicker.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "ActionSheetPicker" 3 | s.version = "1.5.0" 4 | s.summary = "Quickly reproduce the dropdown UIPickerView / ActionSheet functionality from Safari on iPhone/ iOS / CocoaTouch." 5 | s.homepage = "https://github.com/skywinder/ActionSheetPicker-3.0" 6 | s.license = 'BSD' 7 | s.author = { 8 | 'Tim Cinel' => 'email@timcinel.com', 9 | 'Filote Stefan' => 'http://github.com/sfilo', 10 | 'Brett Gibson' => 'http://github.com/brettg', 11 | 'John Garland' => 'http://github.com/johnnyg', 12 | 'Mark van den Broek' => 'http://github.com/heyhoo', 13 | 'Evan Cordell' => 'http://github.com/ecordell', 14 | 'Greg Combs' => 'http://github.com/grgcombs', 15 | 'Hari Karam Singh' => 'http://github.com/Club15CC', 16 | 'Petr Korolev' => 'https://github.com/skywinder' } 17 | s.source = { :git => 'https://github.com/skywinder/ActionSheetPicker-3.0.git', :tag => "#{s.version}" } 18 | s.platform = :ios 19 | s.source_files = 'ActionSheetPicker.h', 'Pickers/*.{h,m}' 20 | s.public_header_files = 'ActionSheetPicker.h', 'Pickers/*.h' 21 | s.framework = 'UIKit' 22 | s.requires_arc = true 23 | end 24 | -------------------------------------------------------------------------------- /ActionSheetPicker.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1C6EE718192BB41600A27994 /* ActionSheetPickerViewController-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1C6EE707192BB41600A27994 /* ActionSheetPickerViewController-iPad.xib */; }; 11 | 1C6EE719192BB41600A27994 /* ActionSheetPickerViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1C6EE708192BB41600A27994 /* ActionSheetPickerViewController.xib */; }; 12 | 1C6EE71A192BB41600A27994 /* ActionSheetPickerAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C6EE70B192BB41600A27994 /* ActionSheetPickerAppDelegate.m */; }; 13 | 1C6EE71B192BB41600A27994 /* ActionSheetPickerCustomPickerDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C6EE70D192BB41600A27994 /* ActionSheetPickerCustomPickerDelegate.m */; }; 14 | 1C6EE71C192BB41600A27994 /* ActionSheetPickerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C6EE70F192BB41600A27994 /* ActionSheetPickerViewController.m */; }; 15 | 1C6EE71D192BB41600A27994 /* NSDate+TCUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C6EE711192BB41600A27994 /* NSDate+TCUtils.m */; }; 16 | 1C6EE71E192BB41600A27994 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1C6EE712192BB41600A27994 /* Default-568h@2x.png */; }; 17 | 1C6EE71F192BB41600A27994 /* MainWindow-iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1C6EE714192BB41600A27994 /* MainWindow-iPad.xib */; }; 18 | 1C6EE720192BB41600A27994 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C6EE715192BB41600A27994 /* main.m */; }; 19 | 1C6EE721192BB41600A27994 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1C6EE716192BB41600A27994 /* MainWindow.xib */; }; 20 | 1C6EE724192BB47000A27994 /* ActionSheetPicker-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1C6EE723192BB47000A27994 /* ActionSheetPicker-Info.plist */; }; 21 | 1C6EE734192BB4F600A27994 /* AbstractActionSheetPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C6EE727192BB4F600A27994 /* AbstractActionSheetPicker.m */; }; 22 | 1C6EE735192BB4F600A27994 /* ActionSheetCustomPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C6EE729192BB4F600A27994 /* ActionSheetCustomPicker.m */; }; 23 | 1C6EE736192BB4F600A27994 /* ActionSheetDatePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C6EE72C192BB4F600A27994 /* ActionSheetDatePicker.m */; }; 24 | 1C6EE737192BB4F600A27994 /* ActionSheetDistancePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C6EE72E192BB4F600A27994 /* ActionSheetDistancePicker.m */; }; 25 | 1C6EE738192BB4F600A27994 /* ActionSheetStringPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C6EE730192BB4F600A27994 /* ActionSheetStringPicker.m */; }; 26 | 1C6EE739192BB4F600A27994 /* DistancePickerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1C6EE732192BB4F600A27994 /* DistancePickerView.m */; }; 27 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 28 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 29 | 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; 30 | /* End PBXBuildFile section */ 31 | 32 | /* Begin PBXFileReference section */ 33 | 1C6EE707192BB41600A27994 /* ActionSheetPickerViewController-iPad.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = "ActionSheetPickerViewController-iPad.xib"; sourceTree = ""; }; 34 | 1C6EE708192BB41600A27994 /* ActionSheetPickerViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ActionSheetPickerViewController.xib; sourceTree = ""; }; 35 | 1C6EE70A192BB41600A27994 /* ActionSheetPickerAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionSheetPickerAppDelegate.h; sourceTree = ""; }; 36 | 1C6EE70B192BB41600A27994 /* ActionSheetPickerAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ActionSheetPickerAppDelegate.m; sourceTree = ""; }; 37 | 1C6EE70C192BB41600A27994 /* ActionSheetPickerCustomPickerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionSheetPickerCustomPickerDelegate.h; sourceTree = ""; }; 38 | 1C6EE70D192BB41600A27994 /* ActionSheetPickerCustomPickerDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ActionSheetPickerCustomPickerDelegate.m; sourceTree = ""; }; 39 | 1C6EE70E192BB41600A27994 /* ActionSheetPickerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionSheetPickerViewController.h; sourceTree = ""; }; 40 | 1C6EE70F192BB41600A27994 /* ActionSheetPickerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ActionSheetPickerViewController.m; sourceTree = ""; }; 41 | 1C6EE710192BB41600A27994 /* NSDate+TCUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+TCUtils.h"; sourceTree = ""; }; 42 | 1C6EE711192BB41600A27994 /* NSDate+TCUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+TCUtils.m"; sourceTree = ""; }; 43 | 1C6EE712192BB41600A27994 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 44 | 1C6EE714192BB41600A27994 /* MainWindow-iPad.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = "MainWindow-iPad.xib"; sourceTree = ""; }; 45 | 1C6EE715192BB41600A27994 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 46 | 1C6EE716192BB41600A27994 /* MainWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; 47 | 1C6EE722192BB47000A27994 /* ActionSheetPicker_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionSheetPicker_Prefix.pch; sourceTree = ""; }; 48 | 1C6EE723192BB47000A27994 /* ActionSheetPicker-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "ActionSheetPicker-Info.plist"; sourceTree = ""; }; 49 | 1C6EE725192BB49E00A27994 /* ActionSheetPicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ActionSheetPicker.h; sourceTree = ""; }; 50 | 1C6EE726192BB4F600A27994 /* AbstractActionSheetPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractActionSheetPicker.h; sourceTree = ""; }; 51 | 1C6EE727192BB4F600A27994 /* AbstractActionSheetPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AbstractActionSheetPicker.m; sourceTree = ""; }; 52 | 1C6EE728192BB4F600A27994 /* ActionSheetCustomPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionSheetCustomPicker.h; sourceTree = ""; }; 53 | 1C6EE729192BB4F600A27994 /* ActionSheetCustomPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ActionSheetCustomPicker.m; sourceTree = ""; }; 54 | 1C6EE72A192BB4F600A27994 /* ActionSheetCustomPickerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionSheetCustomPickerDelegate.h; sourceTree = ""; }; 55 | 1C6EE72B192BB4F600A27994 /* ActionSheetDatePicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionSheetDatePicker.h; sourceTree = ""; }; 56 | 1C6EE72C192BB4F600A27994 /* ActionSheetDatePicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ActionSheetDatePicker.m; sourceTree = ""; }; 57 | 1C6EE72D192BB4F600A27994 /* ActionSheetDistancePicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionSheetDistancePicker.h; sourceTree = ""; }; 58 | 1C6EE72E192BB4F600A27994 /* ActionSheetDistancePicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ActionSheetDistancePicker.m; sourceTree = ""; }; 59 | 1C6EE72F192BB4F600A27994 /* ActionSheetStringPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActionSheetStringPicker.h; sourceTree = ""; }; 60 | 1C6EE730192BB4F600A27994 /* ActionSheetStringPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ActionSheetStringPicker.m; sourceTree = ""; }; 61 | 1C6EE731192BB4F600A27994 /* DistancePickerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DistancePickerView.h; sourceTree = ""; }; 62 | 1C6EE732192BB4F600A27994 /* DistancePickerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DistancePickerView.m; sourceTree = ""; }; 63 | 1CD15A2F192C7A0A00B28881 /* ActionSheetPicker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ActionSheetPicker.app; sourceTree = BUILT_PRODUCTS_DIR; }; 64 | 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 65 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 66 | 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 67 | /* End PBXFileReference section */ 68 | 69 | /* Begin PBXFrameworksBuildPhase section */ 70 | 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { 71 | isa = PBXFrameworksBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, 75 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, 76 | 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */, 77 | ); 78 | runOnlyForDeploymentPostprocessing = 0; 79 | }; 80 | /* End PBXFrameworksBuildPhase section */ 81 | 82 | /* Begin PBXGroup section */ 83 | 1C6EE704192BB41600A27994 /* Example */ = { 84 | isa = PBXGroup; 85 | children = ( 86 | 1C6EE707192BB41600A27994 /* ActionSheetPickerViewController-iPad.xib */, 87 | 1C6EE708192BB41600A27994 /* ActionSheetPickerViewController.xib */, 88 | 1C6EE709192BB41600A27994 /* Classes */, 89 | 1C6EE712192BB41600A27994 /* Default-568h@2x.png */, 90 | 1C6EE713192BB41600A27994 /* iPad */, 91 | 1C6EE715192BB41600A27994 /* main.m */, 92 | 1C6EE716192BB41600A27994 /* MainWindow.xib */, 93 | ); 94 | path = Example; 95 | sourceTree = ""; 96 | }; 97 | 1C6EE709192BB41600A27994 /* Classes */ = { 98 | isa = PBXGroup; 99 | children = ( 100 | 1C6EE70A192BB41600A27994 /* ActionSheetPickerAppDelegate.h */, 101 | 1C6EE725192BB49E00A27994 /* ActionSheetPicker.h */, 102 | 1C6EE70B192BB41600A27994 /* ActionSheetPickerAppDelegate.m */, 103 | 1C6EE70C192BB41600A27994 /* ActionSheetPickerCustomPickerDelegate.h */, 104 | 1C6EE70D192BB41600A27994 /* ActionSheetPickerCustomPickerDelegate.m */, 105 | 1C6EE70E192BB41600A27994 /* ActionSheetPickerViewController.h */, 106 | 1C6EE70F192BB41600A27994 /* ActionSheetPickerViewController.m */, 107 | 1C6EE710192BB41600A27994 /* NSDate+TCUtils.h */, 108 | 1C6EE711192BB41600A27994 /* NSDate+TCUtils.m */, 109 | ); 110 | path = Classes; 111 | sourceTree = ""; 112 | }; 113 | 1C6EE713192BB41600A27994 /* iPad */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | 1C6EE714192BB41600A27994 /* MainWindow-iPad.xib */, 117 | ); 118 | path = iPad; 119 | sourceTree = ""; 120 | }; 121 | 1C6EE733192BB4F600A27994 /* Pickers */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 1C6EE726192BB4F600A27994 /* AbstractActionSheetPicker.h */, 125 | 1C6EE727192BB4F600A27994 /* AbstractActionSheetPicker.m */, 126 | 1C6EE728192BB4F600A27994 /* ActionSheetCustomPicker.h */, 127 | 1C6EE729192BB4F600A27994 /* ActionSheetCustomPicker.m */, 128 | 1C6EE72A192BB4F600A27994 /* ActionSheetCustomPickerDelegate.h */, 129 | 1C6EE72B192BB4F600A27994 /* ActionSheetDatePicker.h */, 130 | 1C6EE72C192BB4F600A27994 /* ActionSheetDatePicker.m */, 131 | 1C6EE72D192BB4F600A27994 /* ActionSheetDistancePicker.h */, 132 | 1C6EE72E192BB4F600A27994 /* ActionSheetDistancePicker.m */, 133 | 1C6EE72F192BB4F600A27994 /* ActionSheetStringPicker.h */, 134 | 1C6EE730192BB4F600A27994 /* ActionSheetStringPicker.m */, 135 | 1C6EE731192BB4F600A27994 /* DistancePickerView.h */, 136 | 1C6EE732192BB4F600A27994 /* DistancePickerView.m */, 137 | ); 138 | name = Pickers; 139 | path = Example/../Pickers; 140 | sourceTree = ""; 141 | }; 142 | 1CD15A30192C7A0A00B28881 /* Products */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 1CD15A2F192C7A0A00B28881 /* ActionSheetPicker.app */, 146 | ); 147 | name = Products; 148 | sourceTree = ""; 149 | }; 150 | 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | 1C6EE733192BB4F600A27994 /* Pickers */, 154 | 1C6EE722192BB47000A27994 /* ActionSheetPicker_Prefix.pch */, 155 | 1C6EE723192BB47000A27994 /* ActionSheetPicker-Info.plist */, 156 | 1C6EE704192BB41600A27994 /* Example */, 157 | 29B97323FDCFA39411CA2CEA /* Frameworks */, 158 | 1CD15A30192C7A0A00B28881 /* Products */, 159 | ); 160 | name = CustomTemplate; 161 | sourceTree = ""; 162 | }; 163 | 29B97323FDCFA39411CA2CEA /* Frameworks */ = { 164 | isa = PBXGroup; 165 | children = ( 166 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, 167 | 1D30AB110D05D00D00671497 /* Foundation.framework */, 168 | 288765A40DF7441C002DB57D /* CoreGraphics.framework */, 169 | ); 170 | name = Frameworks; 171 | sourceTree = ""; 172 | }; 173 | /* End PBXGroup section */ 174 | 175 | /* Begin PBXNativeTarget section */ 176 | 1D6058900D05DD3D006BFB54 /* ActionSheetPicker */ = { 177 | isa = PBXNativeTarget; 178 | buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "ActionSheetPicker" */; 179 | buildPhases = ( 180 | 1D60588D0D05DD3D006BFB54 /* Resources */, 181 | 1D60588E0D05DD3D006BFB54 /* Sources */, 182 | 1D60588F0D05DD3D006BFB54 /* Frameworks */, 183 | ); 184 | buildRules = ( 185 | ); 186 | dependencies = ( 187 | ); 188 | name = ActionSheetPicker; 189 | productName = ActionSheetPicker; 190 | productReference = 1CD15A2F192C7A0A00B28881 /* ActionSheetPicker.app */; 191 | productType = "com.apple.product-type.application"; 192 | }; 193 | /* End PBXNativeTarget section */ 194 | 195 | /* Begin PBXProject section */ 196 | 29B97313FDCFA39411CA2CEA /* Project object */ = { 197 | isa = PBXProject; 198 | attributes = { 199 | LastUpgradeCheck = 0510; 200 | }; 201 | buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "ActionSheetPicker" */; 202 | compatibilityVersion = "Xcode 3.2"; 203 | developmentRegion = English; 204 | hasScannedForEncodings = 1; 205 | knownRegions = ( 206 | English, 207 | Japanese, 208 | French, 209 | German, 210 | ); 211 | mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; 212 | productRefGroup = 1CD15A30192C7A0A00B28881 /* Products */; 213 | projectDirPath = ""; 214 | projectRoot = ""; 215 | targets = ( 216 | 1D6058900D05DD3D006BFB54 /* ActionSheetPicker */, 217 | ); 218 | }; 219 | /* End PBXProject section */ 220 | 221 | /* Begin PBXResourcesBuildPhase section */ 222 | 1D60588D0D05DD3D006BFB54 /* Resources */ = { 223 | isa = PBXResourcesBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | 1C6EE724192BB47000A27994 /* ActionSheetPicker-Info.plist in Resources */, 227 | 1C6EE721192BB41600A27994 /* MainWindow.xib in Resources */, 228 | 1C6EE71F192BB41600A27994 /* MainWindow-iPad.xib in Resources */, 229 | 1C6EE719192BB41600A27994 /* ActionSheetPickerViewController.xib in Resources */, 230 | 1C6EE71E192BB41600A27994 /* Default-568h@2x.png in Resources */, 231 | 1C6EE718192BB41600A27994 /* ActionSheetPickerViewController-iPad.xib in Resources */, 232 | ); 233 | runOnlyForDeploymentPostprocessing = 0; 234 | }; 235 | /* End PBXResourcesBuildPhase section */ 236 | 237 | /* Begin PBXSourcesBuildPhase section */ 238 | 1D60588E0D05DD3D006BFB54 /* Sources */ = { 239 | isa = PBXSourcesBuildPhase; 240 | buildActionMask = 2147483647; 241 | files = ( 242 | 1C6EE737192BB4F600A27994 /* ActionSheetDistancePicker.m in Sources */, 243 | 1C6EE71D192BB41600A27994 /* NSDate+TCUtils.m in Sources */, 244 | 1C6EE720192BB41600A27994 /* main.m in Sources */, 245 | 1C6EE71C192BB41600A27994 /* ActionSheetPickerViewController.m in Sources */, 246 | 1C6EE734192BB4F600A27994 /* AbstractActionSheetPicker.m in Sources */, 247 | 1C6EE71B192BB41600A27994 /* ActionSheetPickerCustomPickerDelegate.m in Sources */, 248 | 1C6EE738192BB4F600A27994 /* ActionSheetStringPicker.m in Sources */, 249 | 1C6EE736192BB4F600A27994 /* ActionSheetDatePicker.m in Sources */, 250 | 1C6EE71A192BB41600A27994 /* ActionSheetPickerAppDelegate.m in Sources */, 251 | 1C6EE735192BB4F600A27994 /* ActionSheetCustomPicker.m in Sources */, 252 | 1C6EE739192BB4F600A27994 /* DistancePickerView.m in Sources */, 253 | ); 254 | runOnlyForDeploymentPostprocessing = 0; 255 | }; 256 | /* End PBXSourcesBuildPhase section */ 257 | 258 | /* Begin XCBuildConfiguration section */ 259 | 1D6058940D05DD3E006BFB54 /* Debug */ = { 260 | isa = XCBuildConfiguration; 261 | buildSettings = { 262 | ALWAYS_SEARCH_USER_PATHS = NO; 263 | CLANG_ENABLE_OBJC_ARC = YES; 264 | COPY_PHASE_STRIP = NO; 265 | GCC_DYNAMIC_NO_PIC = NO; 266 | GCC_OPTIMIZATION_LEVEL = 0; 267 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 268 | GCC_PREFIX_HEADER = ActionSheetPicker_Prefix.pch; 269 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 270 | GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES; 271 | INFOPLIST_FILE = "ActionSheetPicker-Info.plist"; 272 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 273 | PRODUCT_NAME = ActionSheetPicker; 274 | SDKROOT = iphoneos; 275 | TARGETED_DEVICE_FAMILY = "1,2"; 276 | }; 277 | name = Debug; 278 | }; 279 | 1D6058950D05DD3E006BFB54 /* Release */ = { 280 | isa = XCBuildConfiguration; 281 | buildSettings = { 282 | ALWAYS_SEARCH_USER_PATHS = NO; 283 | CLANG_ENABLE_OBJC_ARC = YES; 284 | COPY_PHASE_STRIP = YES; 285 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 286 | GCC_PREFIX_HEADER = ActionSheetPicker_Prefix.pch; 287 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 288 | GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES; 289 | INFOPLIST_FILE = "ActionSheetPicker-Info.plist"; 290 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 291 | PRODUCT_NAME = ActionSheetPicker; 292 | SDKROOT = iphoneos; 293 | TARGETED_DEVICE_FAMILY = "1,2"; 294 | VALIDATE_PRODUCT = YES; 295 | }; 296 | name = Release; 297 | }; 298 | C01FCF4F08A954540054247B /* Debug */ = { 299 | isa = XCBuildConfiguration; 300 | buildSettings = { 301 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 302 | GCC_C_LANGUAGE_STANDARD = c99; 303 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 304 | GCC_WARN_UNUSED_VARIABLE = YES; 305 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 306 | ONLY_ACTIVE_ARCH = YES; 307 | SDKROOT = iphoneos; 308 | }; 309 | name = Debug; 310 | }; 311 | C01FCF5008A954540054247B /* Release */ = { 312 | isa = XCBuildConfiguration; 313 | buildSettings = { 314 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 315 | GCC_C_LANGUAGE_STANDARD = c99; 316 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 317 | GCC_WARN_UNUSED_VARIABLE = YES; 318 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 319 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 320 | SDKROOT = iphoneos; 321 | }; 322 | name = Release; 323 | }; 324 | /* End XCBuildConfiguration section */ 325 | 326 | /* Begin XCConfigurationList section */ 327 | 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "ActionSheetPicker" */ = { 328 | isa = XCConfigurationList; 329 | buildConfigurations = ( 330 | 1D6058940D05DD3E006BFB54 /* Debug */, 331 | 1D6058950D05DD3E006BFB54 /* Release */, 332 | ); 333 | defaultConfigurationIsVisible = 0; 334 | defaultConfigurationName = Release; 335 | }; 336 | C01FCF4E08A954540054247B /* Build configuration list for PBXProject "ActionSheetPicker" */ = { 337 | isa = XCConfigurationList; 338 | buildConfigurations = ( 339 | C01FCF4F08A954540054247B /* Debug */, 340 | C01FCF5008A954540054247B /* Release */, 341 | ); 342 | defaultConfigurationIsVisible = 0; 343 | defaultConfigurationName = Release; 344 | }; 345 | /* End XCConfigurationList section */ 346 | }; 347 | rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; 348 | } 349 | -------------------------------------------------------------------------------- /ActionSheetPicker_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'ActionSheetPicker' target in the 'ActionSheetPicker' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## [Unreleased](https://github.com/TimCinel/ActionSheetPicker/tree/HEAD) 4 | 5 | [Full Changelog](https://github.com/TimCinel/ActionSheetPicker/compare/1.0.9...HEAD) 6 | 7 | **Closed issues:** 8 | 9 | - size popover [\#121](https://github.com/TimCinel/ActionSheetPicker/issues/121) 10 | 11 | - ActionSheetPicker is not dismissed [\#120](https://github.com/TimCinel/ActionSheetPicker/issues/120) 12 | 13 | - Don't show Date Picker on iOS 8 [\#118](https://github.com/TimCinel/ActionSheetPicker/issues/118) 14 | 15 | - Issues with Swift project [\#117](https://github.com/TimCinel/ActionSheetPicker/issues/117) 16 | 17 | - It can not work well on IOS8 [\#116](https://github.com/TimCinel/ActionSheetPicker/issues/116) 18 | 19 | - Issue with iOS 8 beta [\#111](https://github.com/TimCinel/ActionSheetPicker/issues/111) 20 | 21 | - Layout issue in ActionSheetDistancePicker [\#108](https://github.com/TimCinel/ActionSheetPicker/issues/108) 22 | 23 | - CocoaPods spec file is out of date [\#83](https://github.com/TimCinel/ActionSheetPicker/issues/83) 24 | 25 | - Suggestion: Use a prefix [\#52](https://github.com/TimCinel/ActionSheetPicker/issues/52) 26 | 27 | - Problem with popover positioning [\#42](https://github.com/TimCinel/ActionSheetPicker/issues/42) 28 | 29 | - Add minimumDate and maximumDate to UIDatePicker [\#38](https://github.com/TimCinel/ActionSheetPicker/issues/38) 30 | 31 | - UIPopoverController position [\#30](https://github.com/TimCinel/ActionSheetPicker/issues/30) 32 | 33 | - UIPopoverController and UITableViewCell [\#28](https://github.com/TimCinel/ActionSheetPicker/issues/28) 34 | 35 | - Feature request: support for UIPicker views instead of titles [\#16](https://github.com/TimCinel/ActionSheetPicker/issues/16) 36 | 37 | **Merged pull requests:** 38 | 39 | - fixed warning for 64bit compiler [\#115](https://github.com/TimCinel/ActionSheetPicker/pull/115) ([ignazioc](https://github.com/ignazioc)) 40 | 41 | - Add automatically generated change log file. [\#122](https://github.com/TimCinel/ActionSheetPicker/pull/122) ([skywinder](https://github.com/skywinder)) 42 | 43 | - Only include header files [\#119](https://github.com/TimCinel/ActionSheetPicker/pull/119) ([ened](https://github.com/ened)) 44 | 45 | - Here is a full list of fixes from ActionSheetPicker-3.0 [\#114](https://github.com/TimCinel/ActionSheetPicker/pull/114) ([skywinder](https://github.com/skywinder)) 46 | 47 | ## [1.0.9](https://github.com/TimCinel/ActionSheetPicker/tree/1.0.9) (2014-07-07) 48 | 49 | [Full Changelog](https://github.com/TimCinel/ActionSheetPicker/compare/1.0.8...1.0.9) 50 | 51 | **Closed issues:** 52 | 53 | - Rendering strange problem [\#113](https://github.com/TimCinel/ActionSheetPicker/issues/113) 54 | 55 | - Intergrate with multi picker [\#109](https://github.com/TimCinel/ActionSheetPicker/issues/109) 56 | 57 | - Popover not being dimissed when UIBarButtonItem is touched again [\#88](https://github.com/TimCinel/ActionSheetPicker/issues/88) 58 | 59 | - 16 pull requests and 42 issues [\#78](https://github.com/TimCinel/ActionSheetPicker/issues/78) 60 | 61 | - UITextFields don't spawn the ActionSheet when embedded inside a UIScrollView [\#77](https://github.com/TimCinel/ActionSheetPicker/issues/77) 62 | 63 | - Picker doesnt work well on iPad.. [\#76](https://github.com/TimCinel/ActionSheetPicker/issues/76) 64 | 65 | - Picker view goes blank during dismiss animation [\#74](https://github.com/TimCinel/ActionSheetPicker/issues/74) 66 | 67 | - Seems like UItextfield is overridden [\#67](https://github.com/TimCinel/ActionSheetPicker/issues/67) 68 | 69 | - Finicky buttons on ActionSheetDatePicker [\#64](https://github.com/TimCinel/ActionSheetPicker/issues/64) 70 | 71 | **Merged pull requests:** 72 | 73 | - Update AbstractActionSheetPicker.m [\#81](https://github.com/TimCinel/ActionSheetPicker/pull/81) ([GitUser03](https://github.com/GitUser03)) 74 | 75 | ## [1.0.8](https://github.com/TimCinel/ActionSheetPicker/tree/1.0.8) (2014-06-29) 76 | 77 | [Full Changelog](https://github.com/TimCinel/ActionSheetPicker/compare/1.0.7...1.0.8) 78 | 79 | **Merged pull requests:** 80 | 81 | - Accept NSObject as data / rows parameter in ActionSheetStringPicker. The... [\#112](https://github.com/TimCinel/ActionSheetPicker/pull/112) ([copperoxide](https://github.com/copperoxide)) 82 | 83 | - Modified delegate to allow for more customisation [\#110](https://github.com/TimCinel/ActionSheetPicker/pull/110) ([NikDude](https://github.com/NikDude)) 84 | 85 | ## [1.0.7](https://github.com/TimCinel/ActionSheetPicker/tree/1.0.7) (2014-06-20) 86 | 87 | [Full Changelog](https://github.com/TimCinel/ActionSheetPicker/compare/1.0.6...1.0.7) 88 | 89 | ## [1.0.6](https://github.com/TimCinel/ActionSheetPicker/tree/1.0.6) (2014-06-11) 90 | 91 | [Full Changelog](https://github.com/TimCinel/ActionSheetPicker/compare/1.0.5...1.0.6) 92 | 93 | **Closed issues:** 94 | 95 | - ActionSheetPicker not display at its position [\#95](https://github.com/TimCinel/ActionSheetPicker/issues/95) 96 | 97 | - How Do You Use This? [\#41](https://github.com/TimCinel/ActionSheetPicker/issues/41) 98 | 99 | - Blocks [\#35](https://github.com/TimCinel/ActionSheetPicker/issues/35) 100 | 101 | - ActionSheetPicker width on iPad during a landscape orientation [\#33](https://github.com/TimCinel/ActionSheetPicker/issues/33) 102 | 103 | - Support multiple components with different size, and support minimum date for datepicker [\#19](https://github.com/TimCinel/ActionSheetPicker/issues/19) 104 | 105 | **Merged pull requests:** 106 | 107 | - Allow to customise Maximum and Minimum Date of UIDatePicker [\#96](https://github.com/TimCinel/ActionSheetPicker/pull/96) ([ronakjangir47](https://github.com/ronakjangir47)) 108 | 109 | ## [1.0.5](https://github.com/TimCinel/ActionSheetPicker/tree/1.0.5) (2014-05-27) 110 | 111 | [Full Changelog](https://github.com/TimCinel/ActionSheetPicker/compare/1.0.4...1.0.5) 112 | 113 | **Closed issues:** 114 | 115 | - Maintance [\#104](https://github.com/TimCinel/ActionSheetPicker/issues/104) 116 | 117 | - Crash error in iOS7 [\#101](https://github.com/TimCinel/ActionSheetPicker/issues/101) 118 | 119 | - Crash when use on iPhone 5S 7.1 [\#100](https://github.com/TimCinel/ActionSheetPicker/issues/100) 120 | 121 | - Crash for iPhone 5S [\#93](https://github.com/TimCinel/ActionSheetPicker/issues/93) 122 | 123 | - Will it support the new iOS7 design? [\#89](https://github.com/TimCinel/ActionSheetPicker/issues/89) 124 | 125 | - iOS7 [\#86](https://github.com/TimCinel/ActionSheetPicker/issues/86) 126 | 127 | - Linker command failed with exit code 1 [\#84](https://github.com/TimCinel/ActionSheetPicker/issues/84) 128 | 129 | - uitableview multiple uitextfields [\#80](https://github.com/TimCinel/ActionSheetPicker/issues/80) 130 | 131 | - uitableview multiple uitextfields [\#79](https://github.com/TimCinel/ActionSheetPicker/issues/79) 132 | 133 | - Action Sheet Done Button Color [\#71](https://github.com/TimCinel/ActionSheetPicker/issues/71) 134 | 135 | - How to use in storyboard? [\#70](https://github.com/TimCinel/ActionSheetPicker/issues/70) 136 | 137 | - Suggestion on approach - 2 components [\#68](https://github.com/TimCinel/ActionSheetPicker/issues/68) 138 | 139 | - iOS 6 - createToolbarLabelWithTitle - UITextAlignmentCenter [\#65](https://github.com/TimCinel/ActionSheetPicker/issues/65) 140 | 141 | - Keyboard displayed when ActionSheetPicker pops up [\#62](https://github.com/TimCinel/ActionSheetPicker/issues/62) 142 | 143 | - dismiss when tap outside the actionsheet [\#61](https://github.com/TimCinel/ActionSheetPicker/issues/61) 144 | 145 | - Suggestion: enable to hook customButtonPressed on the target view [\#58](https://github.com/TimCinel/ActionSheetPicker/issues/58) 146 | 147 | - ios 3.1.3 error [\#57](https://github.com/TimCinel/ActionSheetPicker/issues/57) 148 | 149 | - Custom Objects [\#51](https://github.com/TimCinel/ActionSheetPicker/issues/51) 150 | 151 | - Origin UIView should resize with animation [\#48](https://github.com/TimCinel/ActionSheetPicker/issues/48) 152 | 153 | - Please add semantic version tags [\#43](https://github.com/TimCinel/ActionSheetPicker/issues/43) 154 | 155 | **Merged pull requests:** 156 | 157 | - fixed position bug [\#97](https://github.com/TimCinel/ActionSheetPicker/pull/97) ([elwerene](https://github.com/elwerene)) 158 | 159 | - Bug fix [\#60](https://github.com/TimCinel/ActionSheetPicker/pull/60) ([0xMarK](https://github.com/0xMarK)) 160 | 161 | - Update Cocoapods [\#107](https://github.com/TimCinel/ActionSheetPicker/pull/107) ([skywinder](https://github.com/skywinder)) 162 | 163 | - Fixed warnings under XCode 4.6 [\#73](https://github.com/TimCinel/ActionSheetPicker/pull/73) ([jossgiffard](https://github.com/jossgiffard)) 164 | 165 | - Updated for iPhone 5 Compatability [\#66](https://github.com/TimCinel/ActionSheetPicker/pull/66) ([Stunner](https://github.com/Stunner)) 166 | 167 | - Done action fix. [\#59](https://github.com/TimCinel/ActionSheetPicker/pull/59) ([0xMarK](https://github.com/0xMarK)) 168 | 169 | - Update Sample/Classes/ActionSheetPickerAppDelegate.m [\#54](https://github.com/TimCinel/ActionSheetPicker/pull/54) ([zfy686868](https://github.com/zfy686868)) 170 | 171 | - added height and weight picker textfields [\#47](https://github.com/TimCinel/ActionSheetPicker/pull/47) ([mikebob](https://github.com/mikebob)) 172 | 173 | ## [1.0.4](https://github.com/TimCinel/ActionSheetPicker/tree/1.0.4) (2014-05-25) 174 | 175 | [Full Changelog](https://github.com/TimCinel/ActionSheetPicker/compare/0.0.4...1.0.4) 176 | 177 | ## [0.0.4](https://github.com/TimCinel/ActionSheetPicker/tree/0.0.4) (2014-05-25) 178 | 179 | [Full Changelog](https://github.com/TimCinel/ActionSheetPicker/compare/1.0.3...0.0.4) 180 | 181 | **Merged pull requests:** 182 | 183 | - Allcrash fixes [\#103](https://github.com/TimCinel/ActionSheetPicker/pull/103) ([skywinder](https://github.com/skywinder)) 184 | 185 | - Fixed deprecated warnings and added podspec file [\#85](https://github.com/TimCinel/ActionSheetPicker/pull/85) ([TheEskil](https://github.com/TheEskil)) 186 | 187 | ## [1.0.3](https://github.com/TimCinel/ActionSheetPicker/tree/1.0.3) (2014-05-21) 188 | 189 | [Full Changelog](https://github.com/TimCinel/ActionSheetPicker/compare/1.0.2...1.0.3) 190 | 191 | ## [1.0.2](https://github.com/TimCinel/ActionSheetPicker/tree/1.0.2) (2014-05-21) 192 | 193 | [Full Changelog](https://github.com/TimCinel/ActionSheetPicker/compare/1.0.1...1.0.2) 194 | 195 | **Merged pull requests:** 196 | 197 | - Update example project [\#106](https://github.com/TimCinel/ActionSheetPicker/pull/106) ([skywinder](https://github.com/skywinder)) 198 | 199 | - Update example project [\#105](https://github.com/TimCinel/ActionSheetPicker/pull/105) ([skywinder](https://github.com/skywinder)) 200 | 201 | ## [1.0.1](https://github.com/TimCinel/ActionSheetPicker/tree/1.0.1) (2014-05-19) 202 | 203 | [Full Changelog](https://github.com/TimCinel/ActionSheetPicker/compare/0.1...1.0.1) 204 | 205 | **Closed issues:** 206 | 207 | - Distance Picker SIGABRT iOS 7.1 iPad [\#98](https://github.com/TimCinel/ActionSheetPicker/issues/98) 208 | 209 | - Cannot initialize a variable of type 'void \(\*\)' error when building [\#72](https://github.com/TimCinel/ActionSheetPicker/issues/72) 210 | 211 | - Button area slightly off [\#55](https://github.com/TimCinel/ActionSheetPicker/issues/55) 212 | 213 | - Dismiss ActionSheetPicker when the app entered background. [\#45](https://github.com/TimCinel/ActionSheetPicker/issues/45) 214 | 215 | **Merged pull requests:** 216 | 217 | - Fix crash [\#102](https://github.com/TimCinel/ActionSheetPicker/pull/102) ([skywinder](https://github.com/skywinder)) 218 | 219 | - Fixed crashes when selecting date in iPhone 5s [\#99](https://github.com/TimCinel/ActionSheetPicker/pull/99) ([barmat](https://github.com/barmat)) 220 | 221 | - warnings removed [\#94](https://github.com/TimCinel/ActionSheetPicker/pull/94) ([mikk22](https://github.com/mikk22)) 222 | 223 | - Fixed compiler warnings related to sel\_getName [\#91](https://github.com/TimCinel/ActionSheetPicker/pull/91) ([greenwoodcm](https://github.com/greenwoodcm)) 224 | 225 | - Deployment target bump to 6.0, getting rid of deprecation warnings [\#90](https://github.com/TimCinel/ActionSheetPicker/pull/90) ([jkrzemie](https://github.com/jkrzemie)) 226 | 227 | - Allow the user to define a custom bar button for done and cancel [\#87](https://github.com/TimCinel/ActionSheetPicker/pull/87) ([MattCBowman](https://github.com/MattCBowman)) 228 | 229 | - Updated source and project for ARC [\#37](https://github.com/TimCinel/ActionSheetPicker/pull/37) ([Air-Craft](https://github.com/Air-Craft)) 230 | 231 | - Transfer ActionSheetPicker to ARC, and updated the sample project. [\#63](https://github.com/TimCinel/ActionSheetPicker/pull/63) ([YuAo](https://github.com/YuAo)) 232 | 233 | - On iPad, point the popovers directly at their container view. [\#49](https://github.com/TimCinel/ActionSheetPicker/pull/49) ([schustafa](https://github.com/schustafa)) 234 | 235 | ## [0.1](https://github.com/TimCinel/ActionSheetPicker/tree/0.1) (2012-05-11) 236 | 237 | [Full Changelog](https://github.com/TimCinel/ActionSheetPicker/compare/v0.1...0.1) 238 | 239 | ## [v0.1](https://github.com/TimCinel/ActionSheetPicker/tree/v0.1) (2012-05-11) 240 | 241 | **Closed issues:** 242 | 243 | - Landscape Picker Cut Off [\#39](https://github.com/TimCinel/ActionSheetPicker/issues/39) 244 | 245 | - Not ARC compatible [\#34](https://github.com/TimCinel/ActionSheetPicker/issues/34) 246 | 247 | - UIActionSheet not closing on iPhone 4.0, 4.1 simulator [\#31](https://github.com/TimCinel/ActionSheetPicker/issues/31) 248 | 249 | - momery leak [\#27](https://github.com/TimCinel/ActionSheetPicker/issues/27) 250 | 251 | - Closing picker during inertial scrolling causes crash [\#26](https://github.com/TimCinel/ActionSheetPicker/issues/26) 252 | 253 | - release problem [\#24](https://github.com/TimCinel/ActionSheetPicker/issues/24) 254 | 255 | - DistancePickerView is required \(Refactor?\) [\#22](https://github.com/TimCinel/ActionSheetPicker/issues/22) 256 | 257 | - ActionSheet Picker wrong size if about to remove keyboard using resign First Responder [\#20](https://github.com/TimCinel/ActionSheetPicker/issues/20) 258 | 259 | - Feature Requests: API extension for better integration [\#18](https://github.com/TimCinel/ActionSheetPicker/issues/18) 260 | 261 | - displayActionPickerWithView not work on 3.2 Simulator [\#15](https://github.com/TimCinel/ActionSheetPicker/issues/15) 262 | 263 | - Popover doesn't show up on ipad [\#14](https://github.com/TimCinel/ActionSheetPicker/issues/14) 264 | 265 | - Orientation Issue [\#13](https://github.com/TimCinel/ActionSheetPicker/issues/13) 266 | 267 | - License? [\#10](https://github.com/TimCinel/ActionSheetPicker/issues/10) 268 | 269 | - target leak? [\#8](https://github.com/TimCinel/ActionSheetPicker/issues/8) 270 | 271 | - Feature: Arbitrary Value Buttons [\#7](https://github.com/TimCinel/ActionSheetPicker/issues/7) 272 | 273 | - Memory leaks? [\#6](https://github.com/TimCinel/ActionSheetPicker/issues/6) 274 | 275 | - Feature Request: ipad support [\#4](https://github.com/TimCinel/ActionSheetPicker/issues/4) 276 | 277 | - Feature Request [\#3](https://github.com/TimCinel/ActionSheetPicker/issues/3) 278 | 279 | **Merged pull requests:** 280 | 281 | - Fix for "Landscape Picker Cut Off" Issue \#39 [\#40](https://github.com/TimCinel/ActionSheetPicker/pull/40) ([stupergenius](https://github.com/stupergenius)) 282 | 283 | - Fix a method attribute mismatch warning. [\#36](https://github.com/TimCinel/ActionSheetPicker/pull/36) ([jparise](https://github.com/jparise)) 284 | 285 | - Issue in iOS 4.1 and below with hiding the UIActionSheet [\#32](https://github.com/TimCinel/ActionSheetPicker/pull/32) ([eloe](https://github.com/eloe)) 286 | 287 | - Fixed spelling/typos with "success" [\#29](https://github.com/TimCinel/ActionSheetPicker/pull/29) ([typeoneerror](https://github.com/typeoneerror)) 288 | 289 | - Pretty big refactor again ... streamlining, abstraction, and some blocks action [\#25](https://github.com/TimCinel/ActionSheetPicker/pull/25) ([grgcombs](https://github.com/grgcombs)) 290 | 291 | - Major refactor: subclasses used for new picker types [\#23](https://github.com/TimCinel/ActionSheetPicker/pull/23) ([grgcombs](https://github.com/grgcombs)) 292 | 293 | - MeasurementPicker Added [\#12](https://github.com/TimCinel/ActionSheetPicker/pull/12) ([ecordell](https://github.com/ecordell)) 294 | 295 | - Show from UIBarButtonItem [\#11](https://github.com/TimCinel/ActionSheetPicker/pull/11) ([heyhoo](https://github.com/heyhoo)) 296 | 297 | - iPad Support [\#9](https://github.com/TimCinel/ActionSheetPicker/pull/9) ([johnnyg](https://github.com/johnnyg)) 298 | 299 | - allow action sheet tile specification, remove duplicate files [\#5](https://github.com/TimCinel/ActionSheetPicker/pull/5) ([brettg](https://github.com/brettg)) 300 | 301 | - Landscape orientation, title and cancel button [\#2](https://github.com/TimCinel/ActionSheetPicker/pull/2) ([sfilo](https://github.com/sfilo)) 302 | 303 | - Licence addition [\#17](https://github.com/TimCinel/ActionSheetPicker/pull/17) ([raven](https://github.com/raven)) 304 | 305 | 306 | 307 | \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* -------------------------------------------------------------------------------- /Example/ActionSheetPickerViewController-iPad.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 57 | 64 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /Example/ActionSheetPickerViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 57 | 67 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /Example/Classes/ActionSheetPicker.h: -------------------------------------------------------------------------------- 1 | // 2 | //Copyright (c) 2011, Tim Cinel 3 | //All rights reserved. 4 | // 5 | //Redistribution and use in source and binary forms, with or without 6 | //modification, are permitted provided that the following conditions are met: 7 | //* Redistributions of source code must retain the above copyright 8 | //notice, this list of conditions and the following disclaimer. 9 | //* Redistributions in binary form must reproduce the above copyright 10 | //notice, this list of conditions and the following disclaimer in the 11 | //documentation and/or other materials provided with the distribution. 12 | //* Neither the name of the nor the 13 | //names of its contributors may be used to endorse or promote products 14 | //derived from this software without specific prior written permission. 15 | // 16 | //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | //DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | 28 | #import "AbstractActionSheetPicker.h" 29 | 30 | #import "ActionSheetCustomPicker.h" 31 | #import "ActionSheetCustomPickerDelegate.h" 32 | #import "ActionSheetStringPicker.h" 33 | #import "ActionSheetDatePicker.h" 34 | #import "ActionSheetDistancePicker.h" 35 | 36 | -------------------------------------------------------------------------------- /Example/Classes/ActionSheetPickerAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | //Copyright (c) 2011, Tim Cinel 3 | //All rights reserved. 4 | // 5 | //Redistribution and use in source and binary forms, with or without 6 | //modification, are permitted provided that the following conditions are met: 7 | //* Redistributions of source code must retain the above copyright 8 | //notice, this list of conditions and the following disclaimer. 9 | //* Redistributions in binary form must reproduce the above copyright 10 | //notice, this list of conditions and the following disclaimer in the 11 | //documentation and/or other materials provided with the distribution. 12 | //* Neither the name of the nor the 13 | //names of its contributors may be used to endorse or promote products 14 | //derived from this software without specific prior written permission. 15 | // 16 | //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | //DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | 28 | 29 | #import 30 | 31 | @class ActionSheetPickerViewController; 32 | 33 | @interface ActionSheetPickerAppDelegate : NSObject 34 | @property (nonatomic, strong) IBOutlet UIWindow *window; 35 | @property (nonatomic, strong) IBOutlet ActionSheetPickerViewController *viewController; 36 | 37 | @end 38 | 39 | -------------------------------------------------------------------------------- /Example/Classes/ActionSheetPickerAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | //Copyright (c) 2011, Tim Cinel 3 | //All rights reserved. 4 | // 5 | //Redistribution and use in source and binary forms, with or without 6 | //modification, are permitted provided that the following conditions are met: 7 | //* Redistributions of source code must retain the above copyright 8 | //notice, this list of conditions and the following disclaimer. 9 | //* Redistributions in binary form must reproduce the above copyright 10 | //notice, this list of conditions and the following disclaimer in the 11 | //documentation and/or other materials provided with the distribution. 12 | //* Neither the name of the nor the 13 | //names of its contributors may be used to endorse or promote products 14 | //derived from this software without specific prior written permission. 15 | // 16 | //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | //DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | 28 | 29 | #import "ActionSheetPickerAppDelegate.h" 30 | #import "ActionSheetPickerViewController.h" 31 | 32 | @implementation ActionSheetPickerAppDelegate 33 | 34 | @synthesize window; 35 | @synthesize viewController; 36 | 37 | 38 | #pragma mark - 39 | #pragma mark Application lifecycle 40 | 41 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 42 | 43 | // Override point for customization after application launch. 44 | 45 | // Add the view controller's view to the window and display. 46 | 47 | if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) 48 | window.tintColor = [UIColor blueColor]; 49 | 50 | window.rootViewController = viewController; 51 | [window makeKeyAndVisible]; 52 | 53 | return YES; 54 | } 55 | 56 | 57 | - (void)applicationWillResignActive:(UIApplication *)application { 58 | /* 59 | 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. 60 | 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. 61 | */ 62 | } 63 | 64 | 65 | - (void)applicationDidEnterBackground:(UIApplication *)application { 66 | /* 67 | 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. 68 | If your application supports background execution, called instead of applicationWillTerminate: when the user quits. 69 | */ 70 | } 71 | 72 | 73 | - (void)applicationWillEnterForeground:(UIApplication *)application { 74 | /* 75 | Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. 76 | */ 77 | } 78 | 79 | 80 | - (void)applicationDidBecomeActive:(UIApplication *)application { 81 | /* 82 | 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. 83 | */ 84 | } 85 | 86 | 87 | - (void)applicationWillTerminate:(UIApplication *)application { 88 | /* 89 | Called when the application is about to terminate. 90 | See also applicationDidEnterBackground:. 91 | */ 92 | } 93 | 94 | 95 | #pragma mark - 96 | #pragma mark Memory management 97 | 98 | - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { 99 | /* 100 | Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. 101 | */ 102 | } 103 | 104 | 105 | 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /Example/Classes/ActionSheetPickerCustomPickerDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ActionSheetPickerCustomPickerDelegate.h 3 | // ActionSheetPicker 4 | // 5 | // Created by on 13/03/2012. 6 | // Copyright (c) 2012 Club 15CC. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ActionSheetPicker.h" 11 | 12 | @interface ActionSheetPickerCustomPickerDelegate : NSObject 13 | { 14 | NSArray *notesToDisplayForKey; 15 | NSArray *scaleNames; 16 | } 17 | 18 | @property (nonatomic, strong) NSString *selectedKey; 19 | @property (nonatomic, strong) NSString *selectedScale; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Example/Classes/ActionSheetPickerCustomPickerDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // ActionSheetPickerCustomPickerDelegate.m 3 | // ActionSheetPicker 4 | // 5 | // Created by on 13/03/2012. 6 | // Copyright (c) 2012 Club 15CC. All rights reserved. 7 | // 8 | 9 | #import "ActionSheetPickerCustomPickerDelegate.h" 10 | 11 | @implementation ActionSheetPickerCustomPickerDelegate 12 | 13 | @synthesize selectedKey, selectedScale; 14 | 15 | - (id)init 16 | { 17 | if (self = [super init]) { 18 | notesToDisplayForKey = [NSArray arrayWithObjects: @"C", @"Db", @"D", @"Eb", @"E", @"F", @"Gb", @"G", @"Ab", @"A", @"Bb", @"B", nil]; 19 | scaleNames = [NSArray arrayWithObjects: @"Major", @"Minor", @"Dorian", @"Spanish Gypsy", nil]; 20 | } 21 | return self; 22 | } 23 | 24 | ///////////////////////////////////////////////////////////////////////// 25 | #pragma mark - ActionSheetCustomPickerDelegate Optional's 26 | ///////////////////////////////////////////////////////////////////////// 27 | - (void)configurePickerView:(UIPickerView *)pickerView 28 | { 29 | // Override default and hide selection indicator 30 | pickerView.showsSelectionIndicator = NO; 31 | } 32 | 33 | - (void)actionSheetPickerDidSucceed:(AbstractActionSheetPicker *)actionSheetPicker origin:(id)origin 34 | { 35 | NSString *resultMessage = [NSString stringWithFormat:@"%@ %@ selected.", 36 | self.selectedKey, 37 | self.selectedScale]; 38 | 39 | [[[UIAlertView alloc] initWithTitle:@"Success!" message:resultMessage delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil] show]; 40 | } 41 | 42 | ///////////////////////////////////////////////////////////////////////// 43 | #pragma mark - UIPickerViewDataSource Implementation 44 | ///////////////////////////////////////////////////////////////////////// 45 | 46 | - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView 47 | { 48 | return 2; 49 | } 50 | 51 | - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component 52 | { 53 | // Returns 54 | switch (component) { 55 | case 0: return [notesToDisplayForKey count]; 56 | case 1: return [scaleNames count]; 57 | default:break; 58 | } 59 | return 0; 60 | } 61 | 62 | ///////////////////////////////////////////////////////////////////////// 63 | #pragma mark UIPickerViewDelegate Implementation 64 | ///////////////////////////////////////////////////////////////////////// 65 | 66 | // returns width of column and height of row for each component. 67 | - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component 68 | { 69 | switch (component) { 70 | case 0: return 60.0f; 71 | case 1: return 260.0f; 72 | default:break; 73 | } 74 | 75 | return 0; 76 | } 77 | /*- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component 78 | { 79 | return 80 | } 81 | */ 82 | // these methods return either a plain UIString, or a view (e.g UILabel) to display the row for the component. 83 | // for the view versions, we cache any hidden and thus unused views and pass them back for reuse. 84 | // If you return back a different object, the old one will be released. the view will be centered in the row rect 85 | - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component 86 | { 87 | switch (component) { 88 | case 0: return [notesToDisplayForKey objectAtIndex:row]; 89 | case 1: return [scaleNames objectAtIndex:row]; 90 | default:break; 91 | } 92 | return nil; 93 | } 94 | 95 | ///////////////////////////////////////////////////////////////////////// 96 | 97 | - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component 98 | { 99 | NSLog(@"Row %i selected in component %i", row, component); 100 | switch (component) { 101 | case 0: 102 | selectedKey = [notesToDisplayForKey objectAtIndex:row]; 103 | return; 104 | 105 | case 1: 106 | selectedScale = [scaleNames objectAtIndex:row]; 107 | return; 108 | default:break; 109 | } 110 | } 111 | 112 | @end 113 | -------------------------------------------------------------------------------- /Example/Classes/ActionSheetPickerViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | //Copyright (c) 2011, Tim Cinel 3 | //All rights reserved. 4 | // 5 | //Redistribution and use in source and binary forms, with or without 6 | //modification, are permitted provided that the following conditions are met: 7 | //* Redistributions of source code must retain the above copyright 8 | //notice, this list of conditions and the following disclaimer. 9 | //* Redistributions in binary form must reproduce the above copyright 10 | //notice, this list of conditions and the following disclaimer in the 11 | //documentation and/or other materials provided with the distribution. 12 | //* Neither the name of the nor the 13 | //names of its contributors may be used to endorse or promote products 14 | //derived from this software without specific prior written permission. 15 | // 16 | //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | //DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | 28 | 29 | #import 30 | #import "ActionSheetPicker.h" 31 | 32 | @class AbstractActionSheetPicker; 33 | @interface ActionSheetPickerViewController : UIViewController 34 | 35 | @property (nonatomic, strong) IBOutlet UITextField *animalTextField; 36 | @property (nonatomic, strong) IBOutlet UITextField *dateTextField; 37 | 38 | @property (nonatomic, strong) NSArray *animals; 39 | @property (nonatomic, assign) NSInteger selectedIndex; 40 | @property (nonatomic, strong) NSDate *selectedDate; 41 | @property (nonatomic, assign) NSInteger selectedBigUnit; 42 | @property (nonatomic, assign) NSInteger selectedSmallUnit; 43 | @property (nonatomic, strong) AbstractActionSheetPicker *actionSheetPicker; 44 | 45 | - (IBAction)selectABlock:(id)sender; 46 | - (IBAction)selectAnAnimal:(id)sender; 47 | - (IBAction)selectADate:(id)sender; 48 | - (IBAction)animalButtonTapped:(UIBarButtonItem *)sender; 49 | - (IBAction)dateButtonTapped:(UIBarButtonItem *)sender; 50 | - (IBAction)selectAMeasurement:(id)sender; 51 | - (IBAction)selectAMusicalScale:(UIControl *)sender; 52 | 53 | @end -------------------------------------------------------------------------------- /Example/Classes/ActionSheetPickerViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | //Copyright (c) 2011, Tim Cinel 3 | //All rights reserved. 4 | // 5 | //Redistribution and use in source and binary forms, with or without 6 | //modification, are permitted provided that the following conditions are met: 7 | //* Redistributions of source code must retain the above copyright 8 | //notice, this list of conditions and the following disclaimer. 9 | //* Redistributions in binary form must reproduce the above copyright 10 | //notice, this list of conditions and the following disclaimer in the 11 | //documentation and/or other materials provided with the distribution. 12 | //* Neither the name of the nor the 13 | //names of its contributors may be used to endorse or promote products 14 | //derived from this software without specific prior written permission. 15 | // 16 | //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | //DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | 28 | 29 | #import "ActionSheetPickerViewController.h" 30 | #import "ActionSheetPicker.h" 31 | #import "NSDate+TCUtils.h" 32 | #import "ActionSheetPickerCustomPickerDelegate.h" 33 | 34 | @interface ActionSheetPickerViewController() 35 | - (void)measurementWasSelectedWithBigUnit:(NSNumber *)bigUnit smallUnit:(NSNumber *)smallUnit element:(id)element; 36 | - (void)dateWasSelected:(NSDate *)selectedDate element:(id)element; 37 | - (void)animalWasSelected:(NSNumber *)selectedIndex element:(id)element; 38 | @end 39 | 40 | @implementation ActionSheetPickerViewController 41 | 42 | @synthesize animalTextField = _animalTextField; 43 | @synthesize dateTextField = _dateTextField; 44 | 45 | @synthesize animals = _animals; 46 | @synthesize selectedIndex = _selectedIndex; 47 | @synthesize selectedDate = _selectedDate; 48 | @synthesize selectedBigUnit = _selectedBigUnit; 49 | @synthesize selectedSmallUnit = _selectedSmallUnit; 50 | @synthesize actionSheetPicker = _actionSheetPicker; 51 | 52 | - (void)viewDidLoad { 53 | [super viewDidLoad]; 54 | self.animals = [NSArray arrayWithObjects:@"Aardvark", @"Beaver", @"Cheetah", @"Deer", @"Elephant", @"Frog", @"Gopher", @"Horse", @"Impala", @"...", @"Zebra", nil]; 55 | self.selectedDate = [NSDate date]; 56 | } 57 | 58 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 59 | { 60 | return YES; 61 | } 62 | 63 | #pragma mark - IBActions 64 | 65 | - (IBAction)selectABlock:(UIControl *)sender { 66 | ActionStringDoneBlock done = ^(ActionSheetStringPicker *picker, NSInteger selectedIndex, id selectedValue) { 67 | if ([sender respondsToSelector:@selector(setText:)]) { 68 | [sender performSelector:@selector(setText:) withObject:selectedValue]; 69 | } 70 | }; 71 | ActionStringCancelBlock cancel = ^(ActionSheetStringPicker *picker) { 72 | NSLog(@"Block Picker Canceled"); 73 | }; 74 | NSArray *colors = [NSArray arrayWithObjects:@"Red", @"Green", @"Blue", @"Orange", nil]; 75 | [ActionSheetStringPicker showPickerWithTitle:@"Select a Block" rows:colors initialSelection:0 doneBlock:done cancelBlock:cancel origin:sender]; 76 | } 77 | 78 | - (IBAction)selectAnAnimal:(UIControl *)sender { 79 | [ActionSheetStringPicker showPickerWithTitle:@"Select Animal" rows:self.animals initialSelection:self.selectedIndex target:self successAction:@selector(animalWasSelected:element:) cancelAction:@selector(actionPickerCancelled:) origin:sender]; 80 | 81 | /* Example ActionSheetPicker using customButtons 82 | self.actionSheetPicker = [[ActionSheetPicker alloc] initWithTitle@"Select Animal" rows:self.animals initialSelection:self.selectedIndex target:self successAction:@selector(itemWasSelected:element:) cancelAction:@selector(actionPickerCancelled:) origin:sender 83 | 84 | [self.actionSheetPicker addCustomButtonWithTitle:@"Special" value:[NSNumber numberWithInt:1]]; 85 | self.actionSheetPicker.hideCancel = YES; 86 | [self.actionSheetPicker showActionSheetPicker]; 87 | */ 88 | } 89 | 90 | - (IBAction)selectADate:(UIControl *)sender { 91 | _actionSheetPicker = [[ActionSheetDatePicker alloc] initWithTitle:@"" datePickerMode:UIDatePickerModeDate selectedDate:self.selectedDate target:self action:@selector(dateWasSelected:element:) origin:sender]; 92 | [self.actionSheetPicker addCustomButtonWithTitle:@"Today" value:[NSDate date]]; 93 | [self.actionSheetPicker addCustomButtonWithTitle:@"Yesterday" value:[[NSDate date] TC_dateByAddingCalendarUnits:NSDayCalendarUnit amount:-1]]; 94 | self.actionSheetPicker.hideCancel = YES; 95 | [self.actionSheetPicker showActionSheetPicker]; 96 | } 97 | 98 | - (IBAction)animalButtonTapped:(UIBarButtonItem *)sender { 99 | [self selectAnAnimal:sender]; 100 | } 101 | 102 | - (IBAction)dateButtonTapped:(UIBarButtonItem *)sender { 103 | [self selectADate:sender]; 104 | } 105 | 106 | - (IBAction)selectAMeasurement:(UIControl *)sender { 107 | [ActionSheetDistancePicker showPickerWithTitle:@"Select Length" bigUnitString:@"m" bigUnitMax:330 selectedBigUnit:self.selectedBigUnit smallUnitString:@"cm" smallUnitMax:99 selectedSmallUnit:self.selectedSmallUnit target:self action:@selector(measurementWasSelectedWithBigUnit:smallUnit:element:) origin:sender]; 108 | } 109 | 110 | - (IBAction)selectAMusicalScale:(UIControl *)sender { 111 | 112 | ActionSheetPickerCustomPickerDelegate *delg = [[ActionSheetPickerCustomPickerDelegate alloc] init]; 113 | [ActionSheetCustomPicker showPickerWithTitle:@"Select Key & Scale" delegate:delg showCancelButton:NO origin:sender]; 114 | } 115 | 116 | #pragma mark - Implementation 117 | 118 | - (void)animalWasSelected:(NSNumber *)selectedIndex element:(id)element { 119 | self.selectedIndex = [selectedIndex intValue]; 120 | 121 | //may have originated from textField or barButtonItem, use an IBOutlet instead of element 122 | self.animalTextField.text = [self.animals objectAtIndex:self.selectedIndex]; 123 | } 124 | 125 | - (void)dateWasSelected:(NSDate *)selectedDate element:(id)element { 126 | self.selectedDate = selectedDate; 127 | 128 | //may have originated from textField or barButtonItem, use an IBOutlet instead of element 129 | self.dateTextField.text = [self.selectedDate description]; 130 | } 131 | 132 | - (void)measurementWasSelectedWithBigUnit:(NSNumber *)bigUnit smallUnit:(NSNumber *)smallUnit element:(id)element { 133 | self.selectedBigUnit = [bigUnit intValue]; 134 | self.selectedSmallUnit = [smallUnit intValue]; 135 | [element setText:[NSString stringWithFormat:@"%i m and %i cm", [bigUnit intValue], [smallUnit intValue]]]; 136 | } 137 | 138 | - (void)actionPickerCancelled:(id)sender { 139 | NSLog(@"Delegate has been informed that ActionSheetPicker was cancelled"); 140 | } 141 | 142 | #pragma mark - UITextFieldDelegate 143 | 144 | - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { 145 | return NO; 146 | } 147 | 148 | 149 | @end 150 | -------------------------------------------------------------------------------- /Example/Classes/NSDate+TCUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+TCUtils.h 3 | // ActionSheetPicker 4 | // 5 | // Created by Tim Cinel on 2011-11-14. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface NSDate(TCUtils) 12 | - (NSDate *)TC_dateByAddingCalendarUnits:(NSCalendarUnit)calendarUnit amount:(NSInteger)amount; 13 | @end 14 | -------------------------------------------------------------------------------- /Example/Classes/NSDate+TCUtils.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+TCUtils.m 3 | // ActionSheetPicker 4 | // 5 | // Created by Tim Cinel on 2011-11-14. 6 | // Copyright (c) 2011 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "NSDate+TCUtils.h" 10 | 11 | @implementation NSDate (TCUtils) 12 | 13 | - (NSDate *)TC_dateByAddingCalendarUnits:(NSCalendarUnit)calendarUnit amount:(NSInteger)amount { 14 | NSDateComponents *components = [[NSDateComponents alloc] init]; 15 | NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; 16 | NSDate *newDate; 17 | 18 | switch (calendarUnit) { 19 | case NSSecondCalendarUnit: 20 | [components setSecond:amount]; 21 | break; 22 | case NSMinuteCalendarUnit: 23 | [components setMinute:amount]; 24 | break; 25 | case NSHourCalendarUnit: 26 | [components setHour:amount]; 27 | break; 28 | case NSDayCalendarUnit: 29 | [components setDay:amount]; 30 | break; 31 | case NSWeekCalendarUnit: 32 | [components setWeek:amount]; 33 | break; 34 | case NSMonthCalendarUnit: 35 | [components setMonth:amount]; 36 | break; 37 | case NSYearCalendarUnit: 38 | [components setYear:amount]; 39 | break; 40 | default: 41 | NSLog(@"addCalendar does not support that calendarUnit!"); 42 | break; 43 | } 44 | 45 | newDate = [gregorian dateByAddingComponents:components toDate:self options:0]; 46 | return newDate; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Example/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimCinel/ActionSheetPicker/b1a0a9d8751600dad09055bb5d3744b6b19e1a50/Example/Default-568h@2x.png -------------------------------------------------------------------------------- /Example/MainWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1024 5 | 10D571 6 | 786 7 | 1038.29 8 | 460.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 112 12 | 13 | 14 | YES 15 | 16 | 17 | 18 | YES 19 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 20 | 21 | 22 | YES 23 | 24 | YES 25 | 26 | 27 | YES 28 | 29 | 30 | 31 | YES 32 | 33 | IBFilesOwner 34 | IBCocoaTouchFramework 35 | 36 | 37 | IBFirstResponder 38 | IBCocoaTouchFramework 39 | 40 | 41 | IBCocoaTouchFramework 42 | 43 | 44 | ActionSheetPickerViewController 45 | 46 | 47 | 1 48 | 49 | IBCocoaTouchFramework 50 | NO 51 | 52 | 53 | 54 | 292 55 | {320, 480} 56 | 57 | 1 58 | MSAxIDEAA 59 | 60 | NO 61 | NO 62 | 63 | IBCocoaTouchFramework 64 | YES 65 | 66 | 67 | 68 | 69 | YES 70 | 71 | 72 | delegate 73 | 74 | 75 | 76 | 4 77 | 78 | 79 | 80 | viewController 81 | 82 | 83 | 84 | 11 85 | 86 | 87 | 88 | window 89 | 90 | 91 | 92 | 14 93 | 94 | 95 | 96 | 97 | YES 98 | 99 | 0 100 | 101 | 102 | 103 | 104 | 105 | -1 106 | 107 | 108 | File's Owner 109 | 110 | 111 | 3 112 | 113 | 114 | ActionSheetPicker App Delegate 115 | 116 | 117 | -2 118 | 119 | 120 | 121 | 122 | 10 123 | 124 | 125 | 126 | 127 | 12 128 | 129 | 130 | 131 | 132 | 133 | 134 | YES 135 | 136 | YES 137 | -1.CustomClassName 138 | -2.CustomClassName 139 | 10.CustomClassName 140 | 10.IBEditorWindowLastContentRect 141 | 10.IBPluginDependency 142 | 12.IBEditorWindowLastContentRect 143 | 12.IBPluginDependency 144 | 3.CustomClassName 145 | 3.IBPluginDependency 146 | 147 | 148 | YES 149 | UIApplication 150 | UIResponder 151 | ActionSheetPickerViewController 152 | {{234, 376}, {320, 480}} 153 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 154 | {{525, 346}, {320, 480}} 155 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 156 | ActionSheetPickerAppDelegate 157 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 158 | 159 | 160 | 161 | YES 162 | 163 | 164 | YES 165 | 166 | 167 | 168 | 169 | YES 170 | 171 | 172 | YES 173 | 174 | 175 | 176 | 15 177 | 178 | 179 | 180 | YES 181 | 182 | UIWindow 183 | UIView 184 | 185 | IBUserSource 186 | 187 | 188 | 189 | 190 | ActionSheetPickerAppDelegate 191 | NSObject 192 | 193 | YES 194 | 195 | YES 196 | viewController 197 | window 198 | 199 | 200 | YES 201 | ActionSheetPickerViewController 202 | UIWindow 203 | 204 | 205 | 206 | YES 207 | 208 | YES 209 | viewController 210 | window 211 | 212 | 213 | YES 214 | 215 | viewController 216 | ActionSheetPickerViewController 217 | 218 | 219 | window 220 | UIWindow 221 | 222 | 223 | 224 | 225 | IBProjectSource 226 | Classes/ActionSheetPickerAppDelegate.h 227 | 228 | 229 | 230 | ActionSheetPickerAppDelegate 231 | NSObject 232 | 233 | IBUserSource 234 | 235 | 236 | 237 | 238 | ActionSheetPickerViewController 239 | UIViewController 240 | 241 | IBProjectSource 242 | Classes/ActionSheetPickerViewController.h 243 | 244 | 245 | 246 | 247 | YES 248 | 249 | NSObject 250 | 251 | IBFrameworkSource 252 | Foundation.framework/Headers/NSError.h 253 | 254 | 255 | 256 | NSObject 257 | 258 | IBFrameworkSource 259 | Foundation.framework/Headers/NSFileManager.h 260 | 261 | 262 | 263 | NSObject 264 | 265 | IBFrameworkSource 266 | Foundation.framework/Headers/NSKeyValueCoding.h 267 | 268 | 269 | 270 | NSObject 271 | 272 | IBFrameworkSource 273 | Foundation.framework/Headers/NSKeyValueObserving.h 274 | 275 | 276 | 277 | NSObject 278 | 279 | IBFrameworkSource 280 | Foundation.framework/Headers/NSKeyedArchiver.h 281 | 282 | 283 | 284 | NSObject 285 | 286 | IBFrameworkSource 287 | Foundation.framework/Headers/NSObject.h 288 | 289 | 290 | 291 | NSObject 292 | 293 | IBFrameworkSource 294 | Foundation.framework/Headers/NSRunLoop.h 295 | 296 | 297 | 298 | NSObject 299 | 300 | IBFrameworkSource 301 | Foundation.framework/Headers/NSThread.h 302 | 303 | 304 | 305 | NSObject 306 | 307 | IBFrameworkSource 308 | Foundation.framework/Headers/NSURL.h 309 | 310 | 311 | 312 | NSObject 313 | 314 | IBFrameworkSource 315 | Foundation.framework/Headers/NSURLConnection.h 316 | 317 | 318 | 319 | NSObject 320 | 321 | IBFrameworkSource 322 | UIKit.framework/Headers/UIAccessibility.h 323 | 324 | 325 | 326 | NSObject 327 | 328 | IBFrameworkSource 329 | UIKit.framework/Headers/UINibLoading.h 330 | 331 | 332 | 333 | NSObject 334 | 335 | IBFrameworkSource 336 | UIKit.framework/Headers/UIResponder.h 337 | 338 | 339 | 340 | UIApplication 341 | UIResponder 342 | 343 | IBFrameworkSource 344 | UIKit.framework/Headers/UIApplication.h 345 | 346 | 347 | 348 | UIResponder 349 | NSObject 350 | 351 | 352 | 353 | UISearchBar 354 | UIView 355 | 356 | IBFrameworkSource 357 | UIKit.framework/Headers/UISearchBar.h 358 | 359 | 360 | 361 | UISearchDisplayController 362 | NSObject 363 | 364 | IBFrameworkSource 365 | UIKit.framework/Headers/UISearchDisplayController.h 366 | 367 | 368 | 369 | UIView 370 | 371 | IBFrameworkSource 372 | UIKit.framework/Headers/UITextField.h 373 | 374 | 375 | 376 | UIView 377 | UIResponder 378 | 379 | IBFrameworkSource 380 | UIKit.framework/Headers/UIView.h 381 | 382 | 383 | 384 | UIViewController 385 | 386 | IBFrameworkSource 387 | UIKit.framework/Headers/UINavigationController.h 388 | 389 | 390 | 391 | UIViewController 392 | 393 | IBFrameworkSource 394 | UIKit.framework/Headers/UIPopoverController.h 395 | 396 | 397 | 398 | UIViewController 399 | 400 | IBFrameworkSource 401 | UIKit.framework/Headers/UISplitViewController.h 402 | 403 | 404 | 405 | UIViewController 406 | 407 | IBFrameworkSource 408 | UIKit.framework/Headers/UITabBarController.h 409 | 410 | 411 | 412 | UIViewController 413 | UIResponder 414 | 415 | IBFrameworkSource 416 | UIKit.framework/Headers/UIViewController.h 417 | 418 | 419 | 420 | UIWindow 421 | UIView 422 | 423 | IBFrameworkSource 424 | UIKit.framework/Headers/UIWindow.h 425 | 426 | 427 | 428 | 429 | 0 430 | IBCocoaTouchFramework 431 | 432 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 433 | 434 | 435 | 436 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 437 | 438 | 439 | YES 440 | ActionSheetPicker.xcodeproj 441 | 3 442 | 112 443 | 444 | 445 | -------------------------------------------------------------------------------- /Example/iPad/MainWindow-iPad.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1056 5 | 10J869 6 | 1306 7 | 1038.35 8 | 461.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 301 12 | 13 | 14 | YES 15 | IBUICustomObject 16 | IBUIWindow 17 | IBUIViewController 18 | IBProxyObject 19 | 20 | 21 | YES 22 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 23 | 24 | 25 | YES 26 | 27 | YES 28 | 29 | 30 | 31 | 32 | YES 33 | 34 | IBFilesOwner 35 | IBIPadFramework 36 | 37 | 38 | IBFirstResponder 39 | IBIPadFramework 40 | 41 | 42 | IBIPadFramework 43 | 44 | 45 | ActionSheetPickerViewController-iPad 46 | 47 | 2 48 | 49 | 50 | 1 51 | 1 52 | 53 | IBIPadFramework 54 | NO 55 | 56 | 57 | 58 | 292 59 | {768, 1024} 60 | 61 | 62 | 1 63 | MSAxIDEAA 64 | 65 | NO 66 | NO 67 | 68 | IBIPadFramework 69 | YES 70 | 71 | 72 | 73 | 74 | YES 75 | 76 | 77 | delegate 78 | 79 | 80 | 81 | 4 82 | 83 | 84 | 85 | viewController 86 | 87 | 88 | 89 | 11 90 | 91 | 92 | 93 | window 94 | 95 | 96 | 97 | 14 98 | 99 | 100 | 101 | 102 | YES 103 | 104 | 0 105 | 106 | 107 | 108 | 109 | 110 | -1 111 | 112 | 113 | File's Owner 114 | 115 | 116 | 3 117 | 118 | 119 | ActionSheetPicker App Delegate 120 | 121 | 122 | -2 123 | 124 | 125 | 126 | 127 | 10 128 | 129 | 130 | 131 | 132 | 12 133 | 134 | 135 | 136 | 137 | 138 | 139 | YES 140 | 141 | YES 142 | -1.CustomClassName 143 | -2.CustomClassName 144 | 10.CustomClassName 145 | 10.IBEditorWindowLastContentRect 146 | 10.IBLastUsedUIStatusBarStylesToTargetRuntimesMap 147 | 10.IBPluginDependency 148 | 12.IBEditorWindowLastContentRect 149 | 12.IBLastUsedUIStatusBarStylesToTargetRuntimesMap 150 | 12.IBPluginDependency 151 | 3.CustomClassName 152 | 3.IBPluginDependency 153 | 154 | 155 | YES 156 | UIApplication 157 | UIResponder 158 | ActionSheetPickerViewController 159 | {{234, 376}, {320, 480}} 160 | 161 | IBCocoaTouchFramework 162 | 163 | 164 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 165 | {{525, 346}, {320, 480}} 166 | 167 | IBCocoaTouchFramework 168 | 169 | 170 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 171 | ActionSheetPickerAppDelegate 172 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 173 | 174 | 175 | 176 | YES 177 | 178 | 179 | 180 | 181 | 182 | YES 183 | 184 | 185 | 186 | 187 | 15 188 | 189 | 190 | 191 | YES 192 | 193 | ActionSheetPickerAppDelegate 194 | NSObject 195 | 196 | YES 197 | 198 | YES 199 | viewController 200 | window 201 | 202 | 203 | YES 204 | ActionSheetPickerViewController 205 | UIWindow 206 | 207 | 208 | 209 | YES 210 | 211 | YES 212 | viewController 213 | window 214 | 215 | 216 | YES 217 | 218 | viewController 219 | ActionSheetPickerViewController 220 | 221 | 222 | window 223 | UIWindow 224 | 225 | 226 | 227 | 228 | IBProjectSource 229 | ./Classes/ActionSheetPickerAppDelegate.h 230 | 231 | 232 | 233 | ActionSheetPickerViewController 234 | UIViewController 235 | 236 | YES 237 | 238 | YES 239 | selectADate 240 | selectAnItem 241 | 242 | 243 | YES 244 | id 245 | id 246 | 247 | 248 | 249 | YES 250 | 251 | YES 252 | selectADate 253 | selectAnItem 254 | 255 | 256 | YES 257 | 258 | selectADate 259 | id 260 | 261 | 262 | selectAnItem 263 | id 264 | 265 | 266 | 267 | 268 | YES 269 | 270 | YES 271 | _dateTextField 272 | _itemTextField 273 | 274 | 275 | YES 276 | UITextField 277 | UITextField 278 | 279 | 280 | 281 | YES 282 | 283 | YES 284 | _dateTextField 285 | _itemTextField 286 | 287 | 288 | YES 289 | 290 | _dateTextField 291 | UITextField 292 | 293 | 294 | _itemTextField 295 | UITextField 296 | 297 | 298 | 299 | 300 | IBProjectSource 301 | ./Classes/ActionSheetPickerViewController.h 302 | 303 | 304 | 305 | 306 | 0 307 | IBIPadFramework 308 | 309 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 310 | 311 | 312 | 313 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 314 | 315 | 316 | YES 317 | 3 318 | 301 319 | 320 | 321 | -------------------------------------------------------------------------------- /Example/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ActionSheetPicker 4 | // 5 | // Created by S3166992 on 6/01/11. 6 | // Copyright __MyCompanyName__ 2011. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) { 12 | 13 | @autoreleasepool { 14 | int retVal = UIApplicationMain(argc, argv, nil, nil); 15 | return retVal; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011, Tim Cinel (see AUTHORS) 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of the nor the 12 | names of its contributors may be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /Pickers/AbstractActionSheetPicker.h: -------------------------------------------------------------------------------- 1 | // 2 | //Copyright (c) 2011, Tim Cinel 3 | //All rights reserved. 4 | // 5 | //Redistribution and use in source and binary forms, with or without 6 | //modification, are permitted provided that the following conditions are met: 7 | //* Redistributions of source code must retain the above copyright 8 | //notice, this list of conditions and the following disclaimer. 9 | //* Redistributions in binary form must reproduce the above copyright 10 | //notice, this list of conditions and the following disclaimer in the 11 | //documentation and/or other materials provided with the distribution. 12 | //* Neither the name of the nor the 13 | //names of its contributors may be used to endorse or promote products 14 | //derived from this software without specific prior written permission. 15 | // 16 | //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | //DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | 28 | #import 29 | 30 | 31 | @interface AbstractActionSheetPicker : NSObject 32 | @property (nonatomic, strong) UIToolbar* toolbar; 33 | @property (nonatomic, copy) NSString *title; 34 | @property (nonatomic, strong) UIView *pickerView; 35 | @property (nonatomic, readonly) CGSize viewSize; 36 | @property (nonatomic, strong) NSMutableArray *customButtons; 37 | @property (nonatomic, assign) BOOL hideCancel; 38 | @property (nonatomic, assign) CGRect presentFromRect; 39 | 40 | // For subclasses. 41 | - (id)initWithTarget:(id)target successAction:(SEL)successAction cancelAction:(SEL)cancelActionOrNil origin:(id)origin; 42 | 43 | // Present the ActionSheetPicker 44 | - (void)showActionSheetPicker; 45 | 46 | // For subclasses. This is used to send a message to the target upon a successful selection and dismissal of the picker (i.e. not canceled). 47 | - (void)notifyTarget:(id)target didSucceedWithAction:(SEL)successAction origin:(id)origin; 48 | 49 | // For subclasses. This is an optional message upon cancelation of the picker. 50 | - (void)notifyTarget:(id)target didCancelWithAction:(SEL)cancelAction origin:(id)origin; 51 | 52 | // For subclasses. This returns a configured picker view. Subclasses should autorelease. 53 | - (UIPickerView *)configuredPickerView; 54 | 55 | // Adds custom buttons to the left of the UIToolbar that select specified values 56 | - (void)addCustomButtonWithTitle:(NSString *)title value:(id)value; 57 | 58 | //For subclasses. This responds to a custom button being pressed. 59 | - (IBAction)customButtonPressed:(id)sender; 60 | 61 | // Allow the user to specify a custom cancel button 62 | - (void) setCancelButton: (UIBarButtonItem *)button; 63 | 64 | // Allow the user to specify a custom done button 65 | - (void) setDoneButton: (UIBarButtonItem *)button; 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /Pickers/AbstractActionSheetPicker.m: -------------------------------------------------------------------------------- 1 | // 2 | //Copyright (c) 2011, Tim Cinel 3 | //All rights reserved. 4 | // 5 | //Redistribution and use in source and binary forms, with or without 6 | //modification, are permitted provided that the following conditions are met: 7 | //* Redistributions of source code must retain the above copyright 8 | //notice, this list of conditions and the following disclaimer. 9 | //* Redistributions in binary form must reproduce the above copyright 10 | //notice, this list of conditions and the following disclaimer in the 11 | //documentation and/or other materials provided with the distribution. 12 | //* Neither the name of the nor the 13 | //names of its contributors may be used to endorse or promote products 14 | //derived from this software without specific prior written permission. 15 | // 16 | //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | //DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | 28 | #import "AbstractActionSheetPicker.h" 29 | #import 30 | #import 31 | 32 | BOOL OSAtLeast(NSString* v) { 33 | return [[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending; 34 | } 35 | 36 | BOOL isIPhone4() { 37 | struct utsname systemInfo; 38 | uname(&systemInfo); 39 | 40 | NSString *modelName = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; 41 | return ([modelName rangeOfString:@"iPhone3"].location != NSNotFound); 42 | } 43 | 44 | @interface AbstractActionSheetPicker() 45 | 46 | @property (nonatomic, strong) UIBarButtonItem *barButtonItem; 47 | @property (nonatomic, strong) UIBarButtonItem *doneBarButtonItem; 48 | @property (nonatomic, strong) UIBarButtonItem *cancelBarButtonItem; 49 | @property (nonatomic, strong) UIView *containerView; 50 | @property (nonatomic, unsafe_unretained) id target; 51 | @property (nonatomic, assign) SEL successAction; 52 | @property (nonatomic, assign) SEL cancelAction; 53 | @property (nonatomic, strong) UIActionSheet *actionSheet; 54 | @property (nonatomic, strong) UIPopoverController *popOverController; 55 | @property (nonatomic, strong) NSObject *selfReference; 56 | 57 | - (void)presentPickerForView:(UIView *)aView; 58 | - (void)configureAndPresentPopoverForView:(UIView *)aView; 59 | - (void)configureAndPresentActionSheetForView:(UIView *)aView; 60 | - (void)presentActionSheet:(UIActionSheet *)actionSheet; 61 | - (void)presentPopover:(UIPopoverController *)popover; 62 | - (void)dismissPicker; 63 | - (BOOL)isViewPortrait; 64 | - (BOOL)isValidOrigin:(id)origin; 65 | - (id)storedOrigin; 66 | - (UIBarButtonItem *)createToolbarLabelWithTitle:(NSString *)aTitle; 67 | - (UIToolbar *)createPickerToolbarWithTitle:(NSString *)aTitle; 68 | - (UIBarButtonItem *)createButtonWithType:(UIBarButtonSystemItem)type target:(id)target action:(SEL)buttonAction; 69 | - (IBAction)actionPickerDone:(id)sender; 70 | - (IBAction)actionPickerCancel:(id)sender; 71 | @end 72 | 73 | @implementation AbstractActionSheetPicker 74 | @synthesize title = _title; 75 | @synthesize containerView = _containerView; 76 | @synthesize barButtonItem = _barButtonItem; 77 | @synthesize target = _target; 78 | @synthesize successAction = _successAction; 79 | @synthesize cancelAction = _cancelAction; 80 | @synthesize actionSheet = _actionSheet; 81 | @synthesize popOverController = _popOverController; 82 | @synthesize selfReference = _selfReference; 83 | @synthesize pickerView = _pickerView; 84 | @dynamic viewSize; 85 | @synthesize customButtons = _customButtons; 86 | @synthesize hideCancel = _hideCancel; 87 | @synthesize presentFromRect = _presentFromRect; 88 | 89 | #pragma mark - Abstract Implementation 90 | 91 | - (id)initWithTarget:(id)target successAction:(SEL)successAction cancelAction:(SEL)cancelActionOrNil origin:(id)origin { 92 | self = [super init]; 93 | if (self) { 94 | self.target = target; 95 | self.successAction = successAction; 96 | self.cancelAction = cancelActionOrNil; 97 | self.presentFromRect = CGRectZero; 98 | 99 | if ([origin isKindOfClass:[UIBarButtonItem class]]) 100 | self.barButtonItem = origin; 101 | else if ([origin isKindOfClass:[UIView class]]) 102 | self.containerView = origin; 103 | else 104 | NSAssert(NO, @"Invalid origin provided to ActionSheetPicker ( %@ )", origin); 105 | 106 | // Initialize default bar buttons so they can be overridden before the 'showActionSheetPicker' is called 107 | UIBarButtonItem *cancelBtn = [self createButtonWithType:UIBarButtonSystemItemCancel target:self action:@selector(actionPickerCancel:)]; 108 | [self setCancelBarButtonItem:cancelBtn]; 109 | UIBarButtonItem *doneButton = [self createButtonWithType:UIBarButtonSystemItemDone target:self action:@selector(actionPickerDone:)]; 110 | [self setDoneBarButtonItem:doneButton]; 111 | 112 | //allows us to use this without needing to store a reference in calling class 113 | self.selfReference = self; 114 | } 115 | return self; 116 | } 117 | 118 | - (void)dealloc { 119 | 120 | //need to clear picker delegates and datasources, otherwise they may call this object after it's gone 121 | if ([self.pickerView respondsToSelector:@selector(setDelegate:)]) 122 | [self.pickerView performSelector:@selector(setDelegate:) withObject:nil]; 123 | 124 | if ([self.pickerView respondsToSelector:@selector(setDataSource:)]) 125 | [self.pickerView performSelector:@selector(setDataSource:) withObject:nil]; 126 | 127 | self.target = nil; 128 | 129 | } 130 | 131 | - (UIView *)configuredPickerView { 132 | NSAssert(NO, @"This is an abstract class, you must use a subclass of AbstractActionSheetPicker (like ActionSheetStringPicker)"); 133 | return nil; 134 | } 135 | 136 | - (void)notifyTarget:(id)target didSucceedWithAction:(SEL)successAction origin:(id)origin { 137 | NSAssert(NO, @"This is an abstract class, you must use a subclass of AbstractActionSheetPicker (like ActionSheetStringPicker)"); 138 | } 139 | 140 | - (void)notifyTarget:(id)target didCancelWithAction:(SEL)cancelAction origin:(id)origin { 141 | if (target && cancelAction && [target respondsToSelector:cancelAction]) { 142 | #pragma clang diagnostic push 143 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 144 | [target performSelector:cancelAction withObject:origin]; 145 | #pragma clang diagnostic pop 146 | } 147 | } 148 | 149 | #pragma mark - Actions 150 | 151 | - (void)showActionSheetPicker { 152 | UIView *masterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.viewSize.width, 260)]; 153 | if (isIPhone4()) { 154 | masterView.backgroundColor = [UIColor colorWithRed:0.97 green:0.97 blue:0.97 alpha:1.0]; 155 | } 156 | self.toolbar = [self createPickerToolbarWithTitle:self.title]; 157 | [masterView addSubview: self.toolbar]; 158 | 159 | //ios7 picker draws a darkened alpha-only region on the first and last 8 pixels horizontally, but blurs the rest of its background. To make the whole popup appear to be edge-to-edge, we have to add blurring to the remaining left and right edges. 160 | if (OSAtLeast(@"7.0")) { 161 | CGRect f = CGRectMake(0,self.toolbar.frame.origin.y, 8, masterView.frame.size.height - self.toolbar.frame.origin.y); 162 | UIToolbar* leftEdge = [[UIToolbar alloc] initWithFrame: f]; 163 | f.origin.x = masterView.frame.size.width - 8; 164 | UIToolbar* rightEdge = [[UIToolbar alloc] initWithFrame: f]; 165 | leftEdge.barTintColor = rightEdge.barTintColor = self.toolbar.barTintColor; 166 | [masterView insertSubview: leftEdge atIndex: 0]; 167 | [masterView insertSubview: rightEdge atIndex: 0]; 168 | } 169 | 170 | self.pickerView = [self configuredPickerView]; 171 | NSAssert(_pickerView != NULL, @"Picker view failed to instantiate, perhaps you have invalid component data."); 172 | [masterView addSubview:_pickerView]; 173 | [self presentPickerForView:masterView]; 174 | } 175 | 176 | - (IBAction)actionPickerDone:(id)sender { 177 | [self notifyTarget:self.target didSucceedWithAction:self.successAction origin:[self storedOrigin]]; 178 | [self dismissPicker]; 179 | } 180 | 181 | - (IBAction)actionPickerCancel:(id)sender { 182 | [self notifyTarget:self.target didCancelWithAction:self.cancelAction origin:[self storedOrigin]]; 183 | [self dismissPicker]; 184 | } 185 | 186 | - (void)dismissPicker { 187 | #if __IPHONE_4_1 <= __IPHONE_OS_VERSION_MAX_ALLOWED 188 | if (self.actionSheet) 189 | #else 190 | if (self.actionSheet && [self.actionSheet isVisible]) 191 | #endif 192 | [_actionSheet dismissWithClickedButtonIndex:0 animated:YES]; 193 | else if (self.popOverController && self.popOverController.popoverVisible) 194 | [_popOverController dismissPopoverAnimated:YES]; 195 | self.actionSheet = nil; 196 | self.popOverController = nil; 197 | self.selfReference = nil; 198 | } 199 | 200 | #pragma mark - Custom Buttons 201 | 202 | - (void)addCustomButtonWithTitle:(NSString *)title value:(id)value { 203 | if (!self.customButtons) 204 | _customButtons = [[NSMutableArray alloc] init]; 205 | if (!title) 206 | title = @""; 207 | if (!value) 208 | value = [NSNumber numberWithInt:0]; 209 | NSDictionary *buttonDetails = [[NSDictionary alloc] initWithObjectsAndKeys:title, @"buttonTitle", value, @"buttonValue", nil]; 210 | [self.customButtons addObject:buttonDetails]; 211 | } 212 | 213 | - (IBAction)customButtonPressed:(id)sender { 214 | UIBarButtonItem *button = (UIBarButtonItem*)sender; 215 | NSInteger index = button.tag; 216 | NSAssert((index >= 0 && index < self.customButtons.count), @"Bad custom button tag: %zd, custom button count: %zd", index, self.customButtons.count); 217 | NSAssert([self.pickerView respondsToSelector:@selector(selectRow:inComponent:animated:)], @"customButtonPressed not overridden, cannot interact with subclassed pickerView"); 218 | NSDictionary *buttonDetails = [self.customButtons objectAtIndex:index]; 219 | NSAssert(buttonDetails != NULL, @"Custom button dictionary is invalid"); 220 | NSInteger buttonValue = [[buttonDetails objectForKey:@"buttonValue"] intValue]; 221 | UIPickerView *picker = (UIPickerView *)self.pickerView; 222 | NSAssert(picker != NULL, @"PickerView is invalid"); 223 | [picker selectRow:buttonValue inComponent:0 animated:YES]; 224 | if ([self respondsToSelector:@selector(pickerView:didSelectRow:inComponent:)]) { 225 | void (*objc_msgSendTyped)(id target, SEL _cmd, id pickerView, NSInteger row, NSInteger component) = (void*)objc_msgSend; // sending Integers as params 226 | objc_msgSendTyped(self, @selector(pickerView:didSelectRow:inComponent:), picker, buttonValue, 0); 227 | } 228 | } 229 | 230 | // Allow the user to specify a custom cancel button 231 | - (void) setCancelButton: (UIBarButtonItem *)button { 232 | [button setTarget:self]; 233 | [button setAction:@selector(actionPickerCancel:)]; 234 | self.cancelBarButtonItem = button; 235 | } 236 | 237 | // Allow the user to specify a custom done button 238 | - (void) setDoneButton: (UIBarButtonItem *)button { 239 | [button setTarget:self]; 240 | [button setAction:@selector(actionPickerDone:)]; 241 | self.doneBarButtonItem = button; 242 | } 243 | 244 | 245 | - (UIToolbar *)createPickerToolbarWithTitle:(NSString *)title { 246 | CGRect frame = CGRectMake(0, 0, self.viewSize.width, 44); 247 | UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:frame]; 248 | pickerToolbar.barStyle = OSAtLeast(@"7.0") ? UIBarStyleDefault : UIBarStyleBlackTranslucent; 249 | NSMutableArray *barItems = [[NSMutableArray alloc] init]; 250 | NSInteger index = 0; 251 | for (NSDictionary *buttonDetails in self.customButtons) { 252 | NSString *buttonTitle = [buttonDetails objectForKey:@"buttonTitle"]; 253 | //NSInteger buttonValue = [[buttonDetails objectForKey:@"buttonValue"] intValue]; 254 | UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:buttonTitle style:UIBarButtonItemStyleBordered target:self action:@selector(customButtonPressed:)]; 255 | button.tag = index; 256 | [barItems addObject:button]; 257 | index++; 258 | } 259 | if (NO == self.hideCancel) { 260 | [barItems addObject:self.cancelBarButtonItem]; 261 | } 262 | UIBarButtonItem *flexSpace = [self createButtonWithType:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; 263 | [barItems addObject:flexSpace]; 264 | if (title){ 265 | UIBarButtonItem *labelButton = [self createToolbarLabelWithTitle:title]; 266 | [barItems addObject:labelButton]; 267 | [barItems addObject:flexSpace]; 268 | } 269 | [barItems addObject:self.doneBarButtonItem]; 270 | 271 | [pickerToolbar setItems:barItems animated:YES]; 272 | return pickerToolbar; 273 | } 274 | 275 | - (UIBarButtonItem *)createToolbarLabelWithTitle:(NSString *)aTitle { 276 | UILabel *toolBarItemlabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 180,30)]; 277 | [toolBarItemlabel setTextAlignment:NSTextAlignmentCenter]; 278 | [toolBarItemlabel setTextColor: OSAtLeast(@"7.0") ? [UIColor blackColor] : [UIColor whiteColor]]; 279 | [toolBarItemlabel setFont:[UIFont boldSystemFontOfSize:16]]; 280 | [toolBarItemlabel setBackgroundColor:[UIColor clearColor]]; 281 | toolBarItemlabel.text = aTitle; 282 | UIBarButtonItem *buttonLabel = [[UIBarButtonItem alloc]initWithCustomView:toolBarItemlabel]; 283 | return buttonLabel; 284 | } 285 | 286 | - (UIBarButtonItem *)createButtonWithType:(UIBarButtonSystemItem)type target:(id)target action:(SEL)buttonAction { 287 | 288 | UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:type target:target action:buttonAction]; 289 | 290 | if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) 291 | [barButton setTintColor: [[UIApplication sharedApplication] keyWindow].tintColor]; 292 | 293 | return barButton; 294 | } 295 | 296 | #pragma mark - Utilities and Accessors 297 | 298 | - (CGSize)viewSize { 299 | if (![self isViewPortrait]) 300 | return CGSizeMake(480, 320); 301 | return CGSizeMake(320, 480); 302 | } 303 | 304 | - (BOOL)isViewPortrait { 305 | return UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation); 306 | } 307 | 308 | - (BOOL)isValidOrigin:(id)origin { 309 | if (!origin) 310 | return NO; 311 | BOOL isButton = [origin isKindOfClass:[UIBarButtonItem class]]; 312 | BOOL isView = [origin isKindOfClass:[UIView class]]; 313 | return (isButton || isView); 314 | } 315 | 316 | - (id)storedOrigin { 317 | if (self.barButtonItem) 318 | return self.barButtonItem; 319 | return self.containerView; 320 | } 321 | 322 | #pragma mark - Popovers and ActionSheets 323 | 324 | - (void)presentPickerForView:(UIView *)aView { 325 | self.presentFromRect = aView.frame; 326 | 327 | if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 328 | [self configureAndPresentPopoverForView:aView]; 329 | else 330 | [self configureAndPresentActionSheetForView:aView]; 331 | } 332 | 333 | - (void)configureAndPresentActionSheetForView:(UIView *)aView { 334 | NSString *paddedSheetTitle = nil; 335 | CGFloat sheetHeight = self.viewSize.height - 47; 336 | if ([self isViewPortrait]) { 337 | paddedSheetTitle = @"\n\n\n"; // looks hacky to me 338 | } else { 339 | NSString *reqSysVer = @"5.0"; 340 | NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; 341 | if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) { 342 | sheetHeight = self.viewSize.width; 343 | } else { 344 | sheetHeight += 103; 345 | } 346 | } 347 | _actionSheet = [[UIActionSheet alloc] initWithTitle:paddedSheetTitle delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil]; 348 | [_actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent]; 349 | [_actionSheet addSubview:aView]; 350 | [self presentActionSheet:_actionSheet]; 351 | 352 | // Use beginAnimations for a smoother popup animation, otherwise the UIActionSheet pops into view 353 | [UIView beginAnimations:nil context:nil]; 354 | _actionSheet.bounds = CGRectMake(0, 0, self.viewSize.width, sheetHeight); 355 | [UIView commitAnimations]; 356 | } 357 | 358 | - (void)presentActionSheet:(UIActionSheet *)actionSheet { 359 | NSParameterAssert(actionSheet != NULL); 360 | if (self.barButtonItem) 361 | [actionSheet showFromBarButtonItem:_barButtonItem animated:YES]; 362 | else if (self.containerView && NO == CGRectIsEmpty(self.presentFromRect)) 363 | [actionSheet showFromRect:_presentFromRect inView:_containerView animated:YES]; 364 | else 365 | [actionSheet showInView:_containerView]; 366 | } 367 | 368 | - (void)configureAndPresentPopoverForView:(UIView *)aView { 369 | UIViewController *viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil]; 370 | viewController.view = aView; 371 | // fix IOS 8 ContentSize issue 372 | if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1) { 373 | viewController.preferredContentSize = viewController.view.frame.size; 374 | } else { 375 | viewController.contentSizeForViewInPopover = viewController.view.frame.size; 376 | } 377 | _popOverController = [[UIPopoverController alloc] initWithContentViewController:viewController]; 378 | [self presentPopover:_popOverController]; 379 | } 380 | 381 | - (void)presentPopover:(UIPopoverController *)popover { 382 | NSParameterAssert(popover != NULL); 383 | if (self.barButtonItem) { 384 | [popover presentPopoverFromBarButtonItem:_barButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 385 | return; 386 | } 387 | else if ((self.containerView)) { 388 | [popover presentPopoverFromRect:_containerView.bounds inView:_containerView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 389 | return; 390 | } 391 | // Unfortunately, things go to hell whenever you try to present a popover from a table view cell. These are failsafes. 392 | UIView *origin = nil; 393 | CGRect presentRect = CGRectZero; 394 | @try { 395 | origin = (_containerView.superview ? _containerView.superview : _containerView); 396 | presentRect = origin.bounds; 397 | [popover presentPopoverFromRect:presentRect inView:origin permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 398 | } 399 | @catch (NSException *exception) { 400 | origin = [[[[UIApplication sharedApplication] keyWindow] rootViewController] view]; 401 | presentRect = CGRectMake(origin.center.x, origin.center.y, 1, 1); 402 | [popover presentPopoverFromRect:presentRect inView:origin permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 403 | } 404 | } 405 | 406 | @end 407 | 408 | -------------------------------------------------------------------------------- /Pickers/ActionSheetCustomPicker.h: -------------------------------------------------------------------------------- 1 | // 2 | // ActionSheetPicker.h 3 | // ActionSheetPicker 4 | // 5 | // Created by on 13/03/2012. 6 | // Copyright (c) 2012 Club 15CC. All rights reserved. 7 | // 8 | #import 9 | #import "AbstractActionSheetPicker.h" 10 | #import "ActionSheetCustomPickerDelegate.h" 11 | 12 | @interface ActionSheetCustomPicker : AbstractActionSheetPicker 13 | { 14 | } 15 | 16 | ///////////////////////////////////////////////////////////////////////// 17 | #pragma mark - Properties 18 | ///////////////////////////////////////////////////////////////////////// 19 | @property (nonatomic, strong) id delegate; 20 | 21 | 22 | ///////////////////////////////////////////////////////////////////////// 23 | #pragma mark - Init Methods 24 | ///////////////////////////////////////////////////////////////////////// 25 | 26 | /** Designated init */ 27 | - (id)initWithTitle:(NSString *)title delegate:(id)delegate showCancelButton:(BOOL)showCancelButton origin:(id)origin; 28 | 29 | /** Convenience class method for creating an launched */ 30 | + (id)showPickerWithTitle:(NSString *)title delegate:(id)delegate showCancelButton:(BOOL)showCancelButton origin:(id)origin; 31 | 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /Pickers/ActionSheetCustomPicker.m: -------------------------------------------------------------------------------- 1 | // 2 | // ActionSheetPicker.m 3 | // ActionSheetPicker 4 | // 5 | // Created by on 13/03/2012. 6 | // Copyright (c) 2012 Club 15CC. All rights reserved. 7 | // 8 | 9 | #import "ActionSheetCustomPicker.h" 10 | 11 | @implementation ActionSheetCustomPicker 12 | 13 | @synthesize delegate = _delegate; 14 | 15 | 16 | ///////////////////////////////////////////////////////////////////////// 17 | #pragma mark - Init 18 | ///////////////////////////////////////////////////////////////////////// 19 | 20 | - (id)initWithTitle:(NSString *)title delegate:(id)delegate showCancelButton:(BOOL)showCancelButton origin:(id)origin 21 | { 22 | if (self = [self initWithTarget:nil successAction:nil cancelAction:nil origin:origin]) {; 23 | 24 | self.title = title; 25 | self.hideCancel = !showCancelButton; 26 | _delegate = delegate; 27 | } 28 | 29 | return self; 30 | } 31 | 32 | ///////////////////////////////////////////////////////////////////////// 33 | 34 | + (id)showPickerWithTitle:(NSString *)title delegate:(id)delegate showCancelButton:(BOOL)showCancelButton origin:(id)origin 35 | { 36 | ActionSheetCustomPicker *picker = [[ActionSheetCustomPicker alloc] initWithTitle:title delegate:delegate showCancelButton:showCancelButton origin:origin]; 37 | [picker showActionSheetPicker]; 38 | return picker; 39 | } 40 | 41 | ///////////////////////////////////////////////////////////////////////// 42 | #pragma mark - AbstractActionSheetPicker fulfilment 43 | ///////////////////////////////////////////////////////////////////////// 44 | 45 | - (UIView *)configuredPickerView { 46 | CGRect pickerFrame = CGRectMake(0, 40, self.viewSize.width, 216); 47 | UIPickerView *pv = [[UIPickerView alloc] initWithFrame:pickerFrame]; 48 | 49 | // Default to our delegate being the picker's delegate and datasource 50 | pv.delegate = _delegate; 51 | pv.dataSource = _delegate; 52 | pv.showsSelectionIndicator = YES; 53 | 54 | // Allow the delegate to override and set additional configs 55 | //to backward compatibility: 56 | if ([_delegate respondsToSelector:@selector(actionSheetPicker:configurePickerView:)]) { 57 | [_delegate actionSheetPicker:self configurePickerView:pv]; 58 | } 59 | self.pickerView = pv; 60 | return pv; 61 | } 62 | 63 | 64 | ///////////////////////////////////////////////////////////////////////// 65 | 66 | - (void)notifyTarget:(id)target didSucceedWithAction:(SEL)successAction origin:(id)origin 67 | { 68 | // Ignore parent args and just notify the delegate 69 | if ([_delegate respondsToSelector:@selector(actionSheetPickerDidSucceed:origin:)]) { 70 | [_delegate actionSheetPickerDidSucceed:self origin:origin]; 71 | } 72 | } 73 | 74 | ///////////////////////////////////////////////////////////////////////// 75 | 76 | - (void)notifyTarget:(id)target didCancelWithAction:(SEL)cancelAction origin:(id)origin 77 | { 78 | // Ignore parent args and just notify the delegate 79 | if ([_delegate respondsToSelector:@selector(actionSheetPickerDidCancel:origin:)]) { 80 | [_delegate actionSheetPickerDidCancel:self origin:origin]; 81 | } 82 | } 83 | 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /Pickers/ActionSheetCustomPickerDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ActionSheetPickerDelegate.h 3 | // ActionSheetPicker 4 | // 5 | // Created by on 13/03/2012. 6 | // Copyright (c) 2012 Club 15CC. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AbstractActionSheetPicker.h" 11 | 12 | @protocol ActionSheetCustomPickerDelegate 13 | 14 | @optional 15 | 16 | /** 17 | Allow the delegate to override default settings for the picker 18 | 19 | Allows for instance, ability to set separate delegates and data sources as well as GUI settings on the UIPickerView 20 | If not defined and explicily overridden then this class will be the delegate and dataSource. 21 | */ 22 | - (void)configurePickerView:(UIPickerView *)pickerView DEPRECATED_ATTRIBUTE; 23 | - (void)actionSheetPicker:(AbstractActionSheetPicker *)actionSheetPicker configurePickerView:(UIPickerView *)pickerView; 24 | 25 | /** 26 | Success callback 27 | 28 | \param actionSheetPicker .pickerView property accesses the picker. Requires a cast to UIView subclass for the picker 29 | \param origin The entity which launched the ActionSheetPicker 30 | */ 31 | - (void)actionSheetPickerDidSucceed:(AbstractActionSheetPicker *)actionSheetPicker origin:(id)origin; 32 | 33 | /** Cancel callback. See actionSheetPickerDidSuccess:origin: */ 34 | - (void)actionSheetPickerDidCancel:(AbstractActionSheetPicker *)actionSheetPicker origin:(id)origin; 35 | 36 | 37 | @required 38 | 39 | @end -------------------------------------------------------------------------------- /Pickers/ActionSheetDatePicker.h: -------------------------------------------------------------------------------- 1 | // 2 | //Copyright (c) 2011, Tim Cinel 3 | //All rights reserved. 4 | // 5 | //Redistribution and use in source and binary forms, with or without 6 | //modification, are permitted provided that the following conditions are met: 7 | //* Redistributions of source code must retain the above copyright 8 | //notice, this list of conditions and the following disclaimer. 9 | //* Redistributions in binary form must reproduce the above copyright 10 | //notice, this list of conditions and the following disclaimer in the 11 | //documentation and/or other materials provided with the distribution. 12 | //* Neither the name of the nor the 13 | //names of its contributors may be used to endorse or promote products 14 | //derived from this software without specific prior written permission. 15 | // 16 | //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | //DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | 28 | #import "AbstractActionSheetPicker.h" 29 | 30 | @interface ActionSheetDatePicker : AbstractActionSheetPicker 31 | 32 | @property (nonatomic) NSDate *minimumDate; 33 | @property (nonatomic) NSDate *maximumDate; 34 | @property (nonatomic) NSCalendar *calendar; 35 | @property (nonatomic) NSTimeZone *timeZone; 36 | @property (nonatomic) NSLocale *locale; 37 | 38 | + (id)showPickerWithTitle:(NSString *)title datePickerMode:(UIDatePickerMode)datePickerMode selectedDate:(NSDate *)selectedDate target:(id)target action:(SEL)action origin:(id)origin; 39 | 40 | - (id)initWithTitle:(NSString *)title datePickerMode:(UIDatePickerMode)datePickerMode selectedDate:(NSDate *)selectedDate target:(id)target action:(SEL)action origin:(id)origin; 41 | 42 | - (void)eventForDatePicker:(id)sender; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Pickers/ActionSheetDatePicker.m: -------------------------------------------------------------------------------- 1 | // 2 | //Copyright (c) 2011, Tim Cinel 3 | //All rights reserved. 4 | // 5 | //Redistribution and use in source and binary forms, with or without 6 | //modification, are permitted provided that the following conditions are met: 7 | //* Redistributions of source code must retain the above copyright 8 | //notice, this list of conditions and the following disclaimer. 9 | //* Redistributions in binary form must reproduce the above copyright 10 | //notice, this list of conditions and the following disclaimer in the 11 | //documentation and/or other materials provided with the distribution. 12 | //* Neither the name of the nor the 13 | //names of its contributors may be used to endorse or promote products 14 | //derived from this software without specific prior written permission. 15 | // 16 | //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | //DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | 28 | 29 | #import "ActionSheetDatePicker.h" 30 | #import 31 | 32 | @interface ActionSheetDatePicker() 33 | @property (nonatomic, assign) UIDatePickerMode datePickerMode; 34 | @property (nonatomic, strong) NSDate *selectedDate; 35 | @end 36 | 37 | @implementation ActionSheetDatePicker 38 | @synthesize selectedDate = _selectedDate; 39 | @synthesize datePickerMode = _datePickerMode; 40 | 41 | + (id)showPickerWithTitle:(NSString *)title 42 | datePickerMode:(UIDatePickerMode)datePickerMode selectedDate:(NSDate *)selectedDate 43 | target:(id)target action:(SEL)action origin:(id)origin { 44 | ActionSheetDatePicker *picker = [[ActionSheetDatePicker alloc] initWithTitle:title datePickerMode:datePickerMode selectedDate:selectedDate target:target action:action origin:origin]; 45 | [picker showActionSheetPicker]; 46 | return picker; 47 | } 48 | 49 | - (id)initWithTitle:(NSString *)title datePickerMode:(UIDatePickerMode)datePickerMode selectedDate:(NSDate *)selectedDate target:(id)target action:(SEL)action origin:(id)origin { 50 | self = [super initWithTarget:target successAction:action cancelAction:nil origin:origin]; 51 | if (self) { 52 | self.title = title; 53 | self.datePickerMode = datePickerMode; 54 | self.selectedDate = selectedDate; 55 | } 56 | return self; 57 | } 58 | 59 | 60 | - (UIView *)configuredPickerView { 61 | CGRect datePickerFrame = CGRectMake(0, 40, self.viewSize.width, 216); 62 | UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:datePickerFrame]; 63 | datePicker.datePickerMode = self.datePickerMode; 64 | datePicker.maximumDate = self.maximumDate; 65 | datePicker.maximumDate = self.minimumDate; 66 | datePicker.calendar = self.calendar; 67 | datePicker.timeZone = self.timeZone; 68 | datePicker.locale = self.locale; 69 | 70 | [datePicker setDate:self.selectedDate animated:NO]; 71 | [datePicker addTarget:self action:@selector(eventForDatePicker:) forControlEvents:UIControlEventValueChanged]; 72 | 73 | //need to keep a reference to the picker so we can clear the DataSource / Delegate when dismissing (not used in this picker, but just in case somebody uses this as a template for another picker) 74 | self.pickerView = datePicker; 75 | 76 | return datePicker; 77 | } 78 | 79 | - (void)notifyTarget:(id)target didSucceedWithAction:(SEL)action origin:(id)origin { 80 | if ([target respondsToSelector:action]) 81 | #pragma clang diagnostic push 82 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 83 | [target performSelector:action withObject:self.selectedDate withObject:origin]; 84 | #pragma clang diagnostic pop 85 | else 86 | NSAssert(NO, @"Invalid target/action ( %s / %s ) combination used for ActionSheetPicker", object_getClassName(target), sel_getName(action)); 87 | } 88 | 89 | - (void)eventForDatePicker:(id)sender { 90 | if (!sender || ![sender isKindOfClass:[UIDatePicker class]]) 91 | return; 92 | UIDatePicker *datePicker = (UIDatePicker *)sender; 93 | self.selectedDate = datePicker.date; 94 | } 95 | 96 | - (void)customButtonPressed:(id)sender { 97 | UIBarButtonItem *button = (UIBarButtonItem*)sender; 98 | NSInteger index = button.tag; 99 | NSAssert((index >= 0 && index < self.customButtons.count), @"Bad custom button tag: %zd, custom button count: %zd", index, self.customButtons.count); 100 | NSAssert([self.pickerView respondsToSelector:@selector(setDate:animated:)], @"Bad pickerView for ActionSheetDatePicker, doesn't respond to setDate:animated:"); 101 | NSDictionary *buttonDetails = [self.customButtons objectAtIndex:index]; 102 | NSDate *itemValue = [buttonDetails objectForKey:@"buttonValue"]; 103 | UIDatePicker *picker = (UIDatePicker *)self.pickerView; 104 | [picker setDate:itemValue animated:YES]; 105 | [self eventForDatePicker:picker]; 106 | } 107 | 108 | @end 109 | -------------------------------------------------------------------------------- /Pickers/ActionSheetDistancePicker.h: -------------------------------------------------------------------------------- 1 | // 2 | //Copyright (c) 2011, Tim Cinel 3 | //All rights reserved. 4 | // 5 | //Redistribution and use in source and binary forms, with or without 6 | //modification, are permitted provided that the following conditions are met: 7 | //* Redistributions of source code must retain the above copyright 8 | //notice, this list of conditions and the following disclaimer. 9 | //* Redistributions in binary form must reproduce the above copyright 10 | //notice, this list of conditions and the following disclaimer in the 11 | //documentation and/or other materials provided with the distribution. 12 | //* Neither the name of the nor the 13 | //names of its contributors may be used to endorse or promote products 14 | //derived from this software without specific prior written permission. 15 | // 16 | //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | //DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | //åLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | 28 | #import "AbstractActionSheetPicker.h" 29 | #import "DistancePickerView.h" 30 | 31 | @interface ActionSheetDistancePicker : AbstractActionSheetPicker 32 | 33 | + (id)showPickerWithTitle:(NSString *)title bigUnitString:(NSString *)bigUnitString bigUnitMax:(NSInteger)bigUnitMax selectedBigUnit:(NSInteger)selectedBigUnit smallUnitString:(NSString*)smallUnitString smallUnitMax:(NSInteger)smallUnitMax selectedSmallUnit:(NSInteger)selectedSmallUnit target:(id)target action:(SEL)action origin:(id)origin; 34 | 35 | - (id)initWithTitle:(NSString *)title bigUnitString:(NSString *)bigUnitString bigUnitMax:(NSInteger)bigUnitMax selectedBigUnit:(NSInteger)selectedBigUnit smallUnitString:(NSString*)smallUnitString smallUnitMax:(NSInteger)smallUnitMax selectedSmallUnit:(NSInteger)selectedSmallUnit target:(id)target action:(SEL)action origin:(id)origin; 36 | @end 37 | -------------------------------------------------------------------------------- /Pickers/ActionSheetDistancePicker.m: -------------------------------------------------------------------------------- 1 | // 2 | //Copyright (c) 2011, Tim Cinel 3 | //All rights reserved. 4 | // 5 | //Redistribution and use in source and binary forms, with or without 6 | //modification, are permitted provided that the following conditions are met: 7 | //* Redistributions of source code must retain the above copyright 8 | //notice, this list of conditions and the following disclaimer. 9 | //* Redistributions in binary form must reproduce the above copyright 10 | //notice, this list of conditions and the following disclaimer in the 11 | //documentation and/or other materials provided with the distribution. 12 | //* Neither the name of the nor the 13 | //names of its contributors may be used to endorse or promote products 14 | //derived from this software without specific prior written permission. 15 | // 16 | //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | //DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | 28 | #import "ActionSheetDistancePicker.h" 29 | #import 30 | 31 | @interface ActionSheetDistancePicker() 32 | @property (nonatomic, strong) NSString *bigUnitString; 33 | @property (nonatomic, assign) NSInteger selectedBigUnit; 34 | @property (nonatomic, assign) NSInteger bigUnitMax; 35 | @property (nonatomic, assign) NSInteger bigUnitDigits; 36 | @property (nonatomic, strong) NSString *smallUnitString; 37 | @property (nonatomic, assign) NSInteger selectedSmallUnit; 38 | @property (nonatomic, assign) NSInteger smallUnitMax; 39 | @property (nonatomic, assign) NSInteger smallUnitDigits; 40 | @end 41 | 42 | @implementation ActionSheetDistancePicker 43 | @synthesize bigUnitString = _bigUnitString; 44 | @synthesize bigUnitMax = _bigUnitMax; 45 | @synthesize bigUnitDigits = _bigUnitDigits; 46 | @synthesize selectedBigUnit = _selectedBigUnit; 47 | @synthesize smallUnitString = _smallUnitString; 48 | @synthesize smallUnitMax = _smallUnitMax; 49 | @synthesize smallUnitDigits = _smallUnitDigits; 50 | @synthesize selectedSmallUnit = _selectedSmallUnit; 51 | 52 | + (id)showPickerWithTitle:(NSString *)title bigUnitString:(NSString *)bigUnitString bigUnitMax:(NSInteger)bigUnitMax selectedBigUnit:(NSInteger)selectedBigUnit smallUnitString:(NSString*)smallUnitString smallUnitMax:(NSInteger)smallUnitMax selectedSmallUnit:(NSInteger)selectedSmallUnit target:(id)target action:(SEL)action origin:(id)origin { 53 | ActionSheetDistancePicker *picker = [[ActionSheetDistancePicker alloc] initWithTitle:title bigUnitString:bigUnitString bigUnitMax:bigUnitMax selectedBigUnit:selectedBigUnit smallUnitString:smallUnitString smallUnitMax:smallUnitMax selectedSmallUnit:selectedSmallUnit target:target action:action origin:origin]; 54 | [picker showActionSheetPicker]; 55 | return picker; 56 | } 57 | 58 | - (id)initWithTitle:(NSString *)title bigUnitString:(NSString *)bigUnitString bigUnitMax:(NSInteger)bigUnitMax selectedBigUnit:(NSInteger)selectedBigUnit smallUnitString:(NSString*)smallUnitString smallUnitMax:(NSInteger)smallUnitMax selectedSmallUnit:(NSInteger)selectedSmallUnit target:(id)target action:(SEL)action origin:(id)origin { 59 | self = [super initWithTarget:target successAction:action cancelAction:nil origin:origin]; 60 | if (self) { 61 | self.title = title; 62 | self.bigUnitString = bigUnitString; 63 | self.bigUnitMax = bigUnitMax; 64 | self.selectedBigUnit = selectedBigUnit; 65 | self.smallUnitString = smallUnitString; 66 | self.smallUnitMax = smallUnitMax; 67 | self.selectedSmallUnit = selectedSmallUnit; 68 | self.bigUnitDigits = [[NSString stringWithFormat:@"%i", self.bigUnitMax] length]; 69 | self.smallUnitDigits = [[NSString stringWithFormat:@"%i", self.smallUnitMax] length]; 70 | } 71 | return self; 72 | } 73 | 74 | 75 | - (UIView *)configuredPickerView { 76 | CGRect distancePickerFrame = CGRectMake(0, 40, self.viewSize.width, 216); 77 | DistancePickerView *picker = [[DistancePickerView alloc] initWithFrame:distancePickerFrame]; 78 | picker.delegate = self; 79 | picker.dataSource = self; 80 | picker.showsSelectionIndicator = YES; 81 | [picker addLabel:self.bigUnitString forComponent:(self.bigUnitDigits - 1) forLongestString:nil]; 82 | [picker addLabel:self.smallUnitString forComponent:(self.bigUnitDigits + self.smallUnitDigits - 1) forLongestString:nil]; 83 | 84 | NSInteger unitSubtract = 0; 85 | NSInteger currentDigit = 0; 86 | 87 | for (int i = 0; i < self.bigUnitDigits; ++i) { 88 | NSInteger factor = (int)pow((double)10, (double)(self.bigUnitDigits - (i+1))); 89 | currentDigit = (( self.selectedBigUnit - unitSubtract ) / factor ) ; 90 | [picker selectRow:currentDigit inComponent:i animated:NO]; 91 | unitSubtract += currentDigit * factor; 92 | } 93 | 94 | unitSubtract = 0; 95 | 96 | for (int i = self.bigUnitDigits; i < self.bigUnitDigits + self.smallUnitDigits; ++i) { 97 | NSInteger factor = (int)pow((double)10, (double)(self.bigUnitDigits + self.smallUnitDigits - (i+1))); 98 | currentDigit = (( self.selectedSmallUnit - unitSubtract ) / factor ) ; 99 | [picker selectRow:currentDigit inComponent:i animated:NO]; 100 | unitSubtract += currentDigit * factor; 101 | } 102 | 103 | //need to keep a reference to the picker so we can clear the DataSource / Delegate when dismissing 104 | self.pickerView = picker; 105 | 106 | return picker; 107 | } 108 | 109 | - (void)notifyTarget:(id)target didSucceedWithAction:(SEL)action origin:(id)origin { 110 | NSInteger bigUnits = 0; 111 | NSInteger smallUnits = 0; 112 | DistancePickerView *picker = (DistancePickerView *)self.pickerView; 113 | for (int i = 0; i < self.bigUnitDigits; ++i) 114 | bigUnits += [picker selectedRowInComponent:i] * (int)pow((double)10, (double)(self.bigUnitDigits - (i + 1))); 115 | 116 | for (int i = self.bigUnitDigits; i < self.bigUnitDigits + self.smallUnitDigits; ++i) 117 | smallUnits += [picker selectedRowInComponent:i] * (int)pow((double)10, (double)((picker.numberOfComponents - i - 1))); 118 | 119 | //sending three objects, so can't use performSelector: 120 | if ([target respondsToSelector:action]) 121 | { 122 | void (*response)(id, SEL, id, id,id) = (void (*)(id, SEL, id, id,id)) objc_msgSend; 123 | response(target, action, [NSNumber numberWithInteger: bigUnits], [NSNumber numberWithInteger: smallUnits], origin); 124 | } 125 | else 126 | NSAssert(NO, @"Invalid target/action ( %s / %s ) combination used for ActionSheetPicker", object_getClassName(target), sel_getName(action)); 127 | } 128 | 129 | #pragma mark - 130 | #pragma mark UIPickerViewDataSource 131 | 132 | - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { 133 | return self.bigUnitDigits + self.smallUnitDigits; 134 | } 135 | 136 | - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { 137 | if (component + 1 <= self.bigUnitDigits) { 138 | if (component == 0) 139 | return self.bigUnitMax / (int)pow((double)10, (double)(self.bigUnitDigits - 1)) + 1; 140 | return 10; 141 | } 142 | if (component == self.bigUnitDigits) 143 | return self.smallUnitMax / (int)pow((double)10, (double)(self.smallUnitDigits - 1)) + 1; 144 | return 10; 145 | } 146 | 147 | - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { 148 | return [NSString stringWithFormat:@"%i", row]; 149 | } 150 | 151 | - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component { 152 | CGFloat totalWidth = pickerView.frame.size.width - 30; 153 | CGFloat bigUnitLabelSize = [self.bigUnitString sizeWithFont:[UIFont boldSystemFontOfSize:20]].width; 154 | CGFloat smallUnitLabelSize = [self.smallUnitString sizeWithFont:[UIFont boldSystemFontOfSize:20]].width; 155 | CGFloat otherSize = (totalWidth - bigUnitLabelSize - smallUnitLabelSize)/(self.bigUnitDigits + self.smallUnitDigits); 156 | if (component == self.bigUnitDigits - 1) 157 | return otherSize + bigUnitLabelSize; 158 | else if (component == self.bigUnitDigits + self.smallUnitDigits - 1) 159 | return otherSize + smallUnitLabelSize; 160 | return otherSize; 161 | } 162 | 163 | 164 | - (void)customButtonPressed:(id)sender { 165 | NSLog(@"Not implemented. If you get around to it, please contribute back to the project :)"); 166 | } 167 | 168 | @end 169 | -------------------------------------------------------------------------------- /Pickers/ActionSheetStringPicker.h: -------------------------------------------------------------------------------- 1 | // 2 | //Copyright (c) 2011, Tim Cinel 3 | //All rights reserved. 4 | // 5 | //Redistribution and use in source and binary forms, with or without 6 | //modification, are permitted provided that the following conditions are met: 7 | //* Redistributions of source code must retain the above copyright 8 | //notice, this list of conditions and the following disclaimer. 9 | //* Redistributions in binary form must reproduce the above copyright 10 | //notice, this list of conditions and the following disclaimer in the 11 | //documentation and/or other materials provided with the distribution. 12 | //* Neither the name of the nor the 13 | //names of its contributors may be used to endorse or promote products 14 | //derived from this software without specific prior written permission. 15 | // 16 | //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | //DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | //åLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | 28 | #import "AbstractActionSheetPicker.h" 29 | 30 | @class ActionSheetStringPicker; 31 | typedef void(^ActionStringDoneBlock)(ActionSheetStringPicker *picker, NSInteger selectedIndex, id selectedValue); 32 | typedef void(^ActionStringCancelBlock)(ActionSheetStringPicker *picker); 33 | 34 | @interface ActionSheetStringPicker : AbstractActionSheetPicker 35 | /* Create and display an action sheet picker. The returned picker is autoreleased. 36 | "origin" must not be empty. It can be either an originating container view or a UIBarButtonItem to use with a popover arrow. 37 | "target" must not be empty. It should respond to "onSuccess" actions. 38 | "rows" is an array of strings to use for the picker's available selection choices. 39 | "initialSelection" is used to establish the initially selected row; 40 | */ 41 | + (id)showPickerWithTitle:(NSString *)title rows:(NSArray *)data initialSelection:(NSInteger)index target:(id)target successAction:(SEL)successAction cancelAction:(SEL)cancelActionOrNil origin:(id)origin; 42 | 43 | // Create an action sheet picker, but don't display until a subsequent call to "showActionPicker". Receiver must release the picker when ready. */ 44 | - (id)initWithTitle:(NSString *)title rows:(NSArray *)data initialSelection:(NSInteger)index target:(id)target successAction:(SEL)successAction cancelAction:(SEL)cancelActionOrNil origin:(id)origin; 45 | 46 | 47 | 48 | + (id)showPickerWithTitle:(NSString *)title rows:(NSArray *)strings initialSelection:(NSInteger)index doneBlock:(ActionStringDoneBlock)doneBlock cancelBlock:(ActionStringCancelBlock)cancelBlock origin:(id)origin; 49 | 50 | - (id)initWithTitle:(NSString *)title rows:(NSArray *)strings initialSelection:(NSInteger)index doneBlock:(ActionStringDoneBlock)doneBlock cancelBlock:(ActionStringCancelBlock)cancelBlockOrNil origin:(id)origin; 51 | 52 | @property (nonatomic, copy) ActionStringDoneBlock onActionSheetDone; 53 | @property (nonatomic, copy) ActionStringCancelBlock onActionSheetCancel; 54 | 55 | @end -------------------------------------------------------------------------------- /Pickers/ActionSheetStringPicker.m: -------------------------------------------------------------------------------- 1 | // 2 | //Copyright (c) 2011, Tim Cinel 3 | //All rights reserved. 4 | // 5 | //Redistribution and use in source and binary forms, with or without 6 | //modification, are permitted provided that the following conditions are met: 7 | //* Redistributions of source code must retain the above copyright 8 | //notice, this list of conditions and the following disclaimer. 9 | //* Redistributions in binary form must reproduce the above copyright 10 | //notice, this list of conditions and the following disclaimer in the 11 | //documentation and/or other materials provided with the distribution. 12 | //* Neither the name of the nor the 13 | //names of its contributors may be used to endorse or promote products 14 | //derived from this software without specific prior written permission. 15 | // 16 | //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | //DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 20 | //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | //åLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | 28 | #import "ActionSheetStringPicker.h" 29 | 30 | @interface ActionSheetStringPicker() 31 | @property (nonatomic,strong) NSArray *data; 32 | @property (nonatomic,assign) NSInteger selectedIndex; 33 | @end 34 | 35 | @implementation ActionSheetStringPicker 36 | @synthesize data = _data; 37 | @synthesize selectedIndex = _selectedIndex; 38 | @synthesize onActionSheetDone = _onActionSheetDone; 39 | @synthesize onActionSheetCancel = _onActionSheetCancel; 40 | 41 | + (id)showPickerWithTitle:(NSString *)title rows:(NSArray *)strings initialSelection:(NSInteger)index doneBlock:(ActionStringDoneBlock)doneBlock cancelBlock:(ActionStringCancelBlock)cancelBlockOrNil origin:(id)origin { 42 | ActionSheetStringPicker * picker = [[ActionSheetStringPicker alloc] initWithTitle:title rows:strings initialSelection:index doneBlock:doneBlock cancelBlock:cancelBlockOrNil origin:origin]; 43 | [picker showActionSheetPicker]; 44 | return picker; 45 | } 46 | 47 | - (id)initWithTitle:(NSString *)title rows:(NSArray *)strings initialSelection:(NSInteger)index doneBlock:(ActionStringDoneBlock)doneBlock cancelBlock:(ActionStringCancelBlock)cancelBlockOrNil origin:(id)origin { 48 | self = [self initWithTitle:title rows:strings initialSelection:index target:nil successAction:nil cancelAction:nil origin:origin]; 49 | if (self) { 50 | self.onActionSheetDone = doneBlock; 51 | self.onActionSheetCancel = cancelBlockOrNil; 52 | } 53 | return self; 54 | } 55 | 56 | + (id)showPickerWithTitle:(NSString *)title rows:(NSArray *)data initialSelection:(NSInteger)index target:(id)target successAction:(SEL)successAction cancelAction:(SEL)cancelActionOrNil origin:(id)origin { 57 | ActionSheetStringPicker *picker = [[ActionSheetStringPicker alloc] initWithTitle:title rows:data initialSelection:index target:target successAction:successAction cancelAction:cancelActionOrNil origin:origin]; 58 | [picker showActionSheetPicker]; 59 | return picker; 60 | } 61 | 62 | - (id)initWithTitle:(NSString *)title rows:(NSArray *)data initialSelection:(NSInteger)index target:(id)target successAction:(SEL)successAction cancelAction:(SEL)cancelActionOrNil origin:(id)origin { 63 | self = [self initWithTarget:target successAction:successAction cancelAction:cancelActionOrNil origin:origin]; 64 | if (self) { 65 | self.data = data; 66 | self.selectedIndex = index; 67 | self.title = title; 68 | } 69 | return self; 70 | } 71 | 72 | 73 | - (UIView *)configuredPickerView { 74 | if (!self.data) 75 | return nil; 76 | CGRect pickerFrame = CGRectMake(0, 40, self.viewSize.width, 216); 77 | UIPickerView *stringPicker = [[UIPickerView alloc] initWithFrame:pickerFrame]; 78 | stringPicker.delegate = self; 79 | stringPicker.dataSource = self; 80 | [stringPicker selectRow:self.selectedIndex inComponent:0 animated:NO]; 81 | if (self.data.count == 0) { 82 | stringPicker.showsSelectionIndicator = NO; 83 | stringPicker.userInteractionEnabled = NO; 84 | } else { 85 | stringPicker.showsSelectionIndicator = YES; 86 | stringPicker.userInteractionEnabled = YES; 87 | } 88 | 89 | //need to keep a reference to the picker so we can clear the DataSource / Delegate when dismissing 90 | self.pickerView = stringPicker; 91 | 92 | return stringPicker; 93 | } 94 | 95 | - (void)notifyTarget:(id)target didSucceedWithAction:(SEL)successAction origin:(id)origin { 96 | if (self.onActionSheetDone) { 97 | id selectedObject = (self.data.count > 0) ? [self.data objectAtIndex:self.selectedIndex] : nil; 98 | _onActionSheetDone(self, self.selectedIndex, selectedObject); 99 | return; 100 | } 101 | else if (target && [target respondsToSelector:successAction]) { 102 | #pragma clang diagnostic push 103 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 104 | [target performSelector:successAction withObject:[NSNumber numberWithInt:self.selectedIndex] withObject:origin]; 105 | #pragma clang diagnostic pop 106 | return; 107 | } 108 | NSLog(@"Invalid target/action ( %s / %s ) combination used for ActionSheetPicker", object_getClassName(target), sel_getName(successAction)); 109 | } 110 | 111 | - (void)notifyTarget:(id)target didCancelWithAction:(SEL)cancelAction origin:(id)origin { 112 | if (self.onActionSheetCancel) { 113 | _onActionSheetCancel(self); 114 | return; 115 | } 116 | else if (target && cancelAction && [target respondsToSelector:cancelAction]) { 117 | #pragma clang diagnostic push 118 | #pragma clang diagnostic ignored "-Warc-performSelector-leaks" 119 | [target performSelector:cancelAction withObject:origin]; 120 | #pragma clang diagnostic pop 121 | } 122 | } 123 | 124 | #pragma mark - UIPickerViewDelegate / DataSource 125 | 126 | - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { 127 | self.selectedIndex = row; 128 | } 129 | 130 | - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { 131 | return 1; 132 | } 133 | 134 | - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { 135 | return self.data.count; 136 | } 137 | 138 | - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { 139 | id obj = [self.data objectAtIndex:row]; 140 | 141 | // return the object if it is already a NSString, 142 | // otherwise, return the description, just like the toString() method in Java 143 | // else, return nil to prevent exception 144 | 145 | if ([obj isKindOfClass:[NSString class]]) 146 | return obj; 147 | 148 | if ([obj respondsToSelector:@selector(description)]) 149 | return [obj performSelector:@selector(description)]; 150 | 151 | return nil; 152 | } 153 | 154 | - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component { 155 | return pickerView.frame.size.width - 30; 156 | } 157 | 158 | @end -------------------------------------------------------------------------------- /Pickers/DistancePickerView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DistancePickerView.h 3 | // 4 | // Created by Evan on 12/27/10. 5 | // Copyright 2010 NCPTT. All rights reserved. 6 | // 7 | // Adapted from LabeledPickerView by Kåre Morstøl (NotTooBad Software). 8 | // This file only Copyright (c) 2009 Kåre Morstøl (NotTooBad Software). 9 | // This file only under the Eclipse public license v1.0 10 | // http://www.eclipse.org/legal/epl-v10.html 11 | 12 | #import 13 | 14 | 15 | @interface DistancePickerView : UIPickerView { 16 | NSMutableDictionary *labels; 17 | } 18 | 19 | - (void) addLabel:(NSString *)labeltext forComponent:(NSUInteger)component forLongestString:(NSString *)longestString; 20 | - (void) updateLabel:(NSString *)labeltext forComponent:(NSUInteger)component; 21 | @end 22 | -------------------------------------------------------------------------------- /Pickers/DistancePickerView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DistancePickerView.m 3 | // 4 | // Created by Evan on 12/27/10. 5 | // Copyright 2010 NCPTT. All rights reserved. 6 | // 7 | // Adapted from LabeledPickerView by Kåre Morstøl (NotTooBad Software). 8 | // This file only Copyright (c) 2009 Kåre Morstøl (NotTooBad Software). 9 | // This file only under the Eclipse public license v1.0 10 | // http://www.eclipse.org/legal/epl-v10.html 11 | 12 | #import "DistancePickerView.h" 13 | 14 | 15 | @implementation DistancePickerView 16 | 17 | 18 | - (id)initWithFrame:(CGRect)frame { 19 | 20 | self = [super initWithFrame:frame]; 21 | if (self) { 22 | labels = [[NSMutableDictionary alloc] initWithCapacity:2]; 23 | } 24 | return self; 25 | } 26 | 27 | - (void) addLabel:(NSString *)labeltext forComponent:(NSUInteger)component forLongestString:(NSString *)longestString { 28 | [labels setObject:labeltext forKey:[NSNumber numberWithInt:component]]; 29 | 30 | NSString *keyName = [NSString stringWithFormat:@"%@_%@", @"longestString", [NSNumber numberWithInt:component]]; 31 | 32 | if(!longestString) { 33 | longestString = labeltext; 34 | } 35 | 36 | [labels setObject:longestString forKey:keyName]; 37 | } 38 | 39 | - (void) updateLabel:(NSString *)labeltext forComponent:(NSUInteger)component { 40 | 41 | UILabel *theLabel = (UILabel*)[self viewWithTag:component + 1]; 42 | 43 | // Update label if it doesn’t match current label 44 | if (![theLabel.text isEqualToString:labeltext]) { 45 | 46 | NSString *keyName = [NSString stringWithFormat:@"%@_%@", @"longestString", [NSNumber numberWithInt:component]]; 47 | NSString *longestString = [labels objectForKey:keyName]; 48 | 49 | // Update label array with our new string value 50 | [self addLabel:labeltext forComponent:component forLongestString:longestString]; 51 | 52 | // change label during fade out/in 53 | [UIView beginAnimations:nil context:NULL]; 54 | [UIView setAnimationDuration:0.75]; 55 | [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 56 | theLabel.alpha = 0.00; 57 | theLabel.text = labeltext; 58 | theLabel.alpha = 1.00; 59 | [UIView commitAnimations]; 60 | } 61 | 62 | } 63 | 64 | /** 65 | Adds the labels to the view, below the selection indicator glass. 66 | The labels are aligned to the right side of the wheel. 67 | The delegate is responsible for providing enough width for both the value and the label. 68 | */ 69 | - (void)didMoveToWindow { 70 | // exit if view is removed from the window or there are no labels. 71 | if (!self.window || [labels count] == 0) 72 | return; 73 | 74 | UIFont *labelfont = [UIFont boldSystemFontOfSize:20]; 75 | 76 | // find the width of all the wheels combined 77 | CGFloat widthofwheels = 0; 78 | for (int i=0; i NSFoundationVersionNumber_iOS_6_1) { 137 | UIView * o = [[self.subviews[0] subviews] objectAtIndex:([[self.subviews[0] subviews] count] - 1) ]; 138 | UIView *subview = [[o subviews] objectAtIndex:2]; 139 | UIView * view = [[subview.subviews objectAtIndex:0] subviews][1]; 140 | [self insertSubview:label aboveSubview:view]; 141 | } 142 | else { 143 | [self insertSubview:label atIndex:[self.subviews count]-3]; 144 | } 145 | // otherwise add label as the 5th, 10th, 15th etc view from the top 146 | else 147 | { 148 | if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) { 149 | [self insertSubview:label aboveSubview:[[self.subviews[0] subviews] objectAtIndex:component]]; 150 | } 151 | else { 152 | [self insertSubview:label aboveSubview:[self.subviews objectAtIndex:5*(component+1)]]; 153 | } 154 | 155 | } 156 | } else 157 | // there is no selection indicator, so just add it to the top 158 | [self addSubview:label]; 159 | 160 | } 161 | 162 | if ([self.delegate respondsToSelector:@selector(pickerView:didSelectRow:inComponent:)]) 163 | [self.delegate pickerView:self didSelectRow:[self selectedRowInComponent:component] inComponent:component]; 164 | } 165 | 166 | } 167 | 168 | } 169 | 170 | 171 | 172 | @end 173 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## This version is deprecated: use [**ActionSheetPicker-3.0**](https://github.com/skywinder/ActionSheetPicker-3.0) instead. 2 | 3 | This repo is **outdated**. You can find new version of ActionSheetPicker (iOS 8 compatible alredy) here: [**ActionSheetPicker-3.0**](https://github.com/skywinder/ActionSheetPicker-3.0). 4 | 5 | I try to resolve a lot of pull requests and issues in this repo by time, but new updates will be appeared in https://github.com/skywinder/ActionSheetPicker-3.0. I forked from this repo and implement a bunch of fixes. 6 | 7 | 8 | *Regards,* 9 | *Petr Korolev.* 10 | 11 | ## Credits ## 12 | 13 | Thanks to all of the contributors for making ActionSheetPicker better for the iOS developer community. See AUTHORS for details. 14 | 15 | 16 | ### Contributors ### 17 | 18 | [Filote Stefan](http://github.com/sfilo) 19 | 20 | [Brett Gibson](http://github.com/brettg) 21 | 22 | [John Garland](http://github.com/johnnyg) (iPad!) 23 | 24 | [Mark van den Broek](http://github.com/heyhoo) 25 | 26 | [Evan Cordell](http://github.com/ecordell) 27 | 28 | [Greg Combs](http://github.com/grgcombs) (Refactor!) 29 | 30 | [Petr Korolev](http://github.com/skywinder) (Update, crashfix, update for iOS7, new pickers) 31 | 32 | [Nikos Mouzakitis](http://github.com/NikDude) 33 | 34 | ### Creator ### 35 | 36 | [Tim Cinel](http://github.com/TimCinel) 37 | 38 | [@TimCinel](http://twitter.com/TimCinel) 39 | 40 | [timcinel.com/](http://www.timcinel.com/) 41 | -------------------------------------------------------------------------------- /Screenshots/date.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimCinel/ActionSheetPicker/b1a0a9d8751600dad09055bb5d3744b6b19e1a50/Screenshots/date.png -------------------------------------------------------------------------------- /Screenshots/distance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimCinel/ActionSheetPicker/b1a0a9d8751600dad09055bb5d3744b6b19e1a50/Screenshots/distance.png -------------------------------------------------------------------------------- /Screenshots/ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimCinel/ActionSheetPicker/b1a0a9d8751600dad09055bb5d3744b6b19e1a50/Screenshots/ipad.png -------------------------------------------------------------------------------- /Screenshots/string.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TimCinel/ActionSheetPicker/b1a0a9d8751600dad09055bb5d3744b6b19e1a50/Screenshots/string.png --------------------------------------------------------------------------------