├── UIControlSoundDemo ├── UIControlSoundDemo │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── Default.png │ ├── Default@2x.png │ ├── Default-568h@2x.png │ ├── Resources │ │ ├── tap-fuzzy.aif │ │ ├── tap-kissy.aif │ │ └── slide-rock.aif │ ├── DemoViewController.m │ ├── DemoViewController.h │ ├── AppDelegate.h │ ├── main.m │ ├── UIControlSoundDemo-Prefix.pch │ ├── UIControlSoundDemo-Info.plist │ ├── AppDelegate.m │ └── DemoViewController.xib └── UIControlSoundDemo.xcodeproj │ └── project.pbxproj ├── .gitignore ├── UIControl+SoundForControlEvents.h ├── README.md └── UIControl+SoundForControlEvents.m /UIControlSoundDemo/UIControlSoundDemo/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /UIControlSoundDemo/UIControlSoundDemo/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/UIControl-Sound/HEAD/UIControlSoundDemo/UIControlSoundDemo/Default.png -------------------------------------------------------------------------------- /UIControlSoundDemo/UIControlSoundDemo/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/UIControl-Sound/HEAD/UIControlSoundDemo/UIControlSoundDemo/Default@2x.png -------------------------------------------------------------------------------- /UIControlSoundDemo/UIControlSoundDemo/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/UIControl-Sound/HEAD/UIControlSoundDemo/UIControlSoundDemo/Default-568h@2x.png -------------------------------------------------------------------------------- /UIControlSoundDemo/UIControlSoundDemo/Resources/tap-fuzzy.aif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/UIControl-Sound/HEAD/UIControlSoundDemo/UIControlSoundDemo/Resources/tap-fuzzy.aif -------------------------------------------------------------------------------- /UIControlSoundDemo/UIControlSoundDemo/Resources/tap-kissy.aif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/UIControl-Sound/HEAD/UIControlSoundDemo/UIControlSoundDemo/Resources/tap-kissy.aif -------------------------------------------------------------------------------- /UIControlSoundDemo/UIControlSoundDemo/Resources/slide-rock.aif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuAo/UIControl-Sound/HEAD/UIControlSoundDemo/UIControlSoundDemo/Resources/slide-rock.aif -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | DerivedData 18 | .idea/ 19 | -------------------------------------------------------------------------------- /UIControlSoundDemo/UIControlSoundDemo/DemoViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // DemoViewController.m 3 | // UIControlSoundDemo 4 | // 5 | // Created by YuAo on 3/2/13. 6 | // Copyright (c) 2013 YuAo. All rights reserved. 7 | // 8 | 9 | #import "DemoViewController.h" 10 | 11 | @implementation DemoViewController 12 | @end 13 | -------------------------------------------------------------------------------- /UIControlSoundDemo/UIControlSoundDemo/DemoViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // DemoViewController.h 3 | // UIControlSoundDemo 4 | // 5 | // Created by YuAo on 3/2/13. 6 | // Copyright (c) 2013 YuAo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface DemoViewController : UIViewController 12 | @end 13 | -------------------------------------------------------------------------------- /UIControlSoundDemo/UIControlSoundDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // UIControlSoundDemo 4 | // 5 | // Created by YuAo on 3/2/13. 6 | // Copyright (c) 2013 YuAo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /UIControlSoundDemo/UIControlSoundDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // UIControlSoundDemo 4 | // 5 | // Created by YuAo on 3/2/13. 6 | // Copyright (c) 2013 YuAo. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /UIControlSoundDemo/UIControlSoundDemo/UIControlSoundDemo-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'UIControlSoundDemo' target in the 'UIControlSoundDemo' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_4_0 8 | #warning "This project uses features only available in iOS SDK 4.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /UIControl+SoundForControlEvents.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIControl+SoundForControlEvents.h 3 | // 4 | // Created by YuAo on 3/2/13. 5 | // Copyright (c) 2013 YuAo. All rights reserved. 6 | // 7 | 8 | #import 9 | #import 10 | 11 | @interface UIControl (SoundForControlEvents) 12 | 13 | // Add a sound for particular event. you can call this multiple times and you can specify multiple sounds for a particular event. 14 | - (void)addSoundWithContentsOfFile:(NSString *)soundFilePath forControlEvents:(UIControlEvents)controlEvents UI_APPEARANCE_SELECTOR; 15 | 16 | // Remove a sound for particular event. 17 | - (void)removeSoundWithContentsOfFile:(NSString *)soundFilePath forControlEvents:(UIControlEvents)controlEvents UI_APPEARANCE_SELECTOR; 18 | 19 | // Remove all sounds for particular event. 20 | - (void)removeSoundsForControlEvents:(UIControlEvents)controlEvents UI_APPEARANCE_SELECTOR; 21 | 22 | @end 23 | 24 | @interface WUUIControlSoundManager : NSObject 25 | 26 | + (instancetype)sharedSoundManager; 27 | 28 | - (SEL)selectorForPlayingSoundFileAtPath:(NSString *)soundFilePath; 29 | 30 | @end -------------------------------------------------------------------------------- /UIControlSoundDemo/UIControlSoundDemo/UIControlSoundDemo-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | YuAo.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /UIControlSoundDemo/UIControlSoundDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // UIControlSoundDemo 4 | // 5 | // Created by YuAo on 3/2/13. 6 | // Copyright (c) 2013 YuAo. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "DemoViewController.h" 11 | #import "UIControl+SoundForControlEvents.h" 12 | 13 | @implementation AppDelegate 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 18 | 19 | [self addSoundForUIControls]; 20 | 21 | self.window.rootViewController = [[DemoViewController alloc] initWithNibName:NSStringFromClass(DemoViewController.class) bundle:nil]; 22 | [self.window makeKeyAndVisible]; 23 | return YES; 24 | } 25 | 26 | - (void)addSoundForUIControls { 27 | NSString *soundAFilePath = [NSBundle.mainBundle pathForResource:@"tap-kissy" ofType:@"aif"]; 28 | [[UIButton appearance] addSoundWithContentsOfFile:soundAFilePath forControlEvents:UIControlEventTouchUpInside]; 29 | 30 | NSString *soundBFilePath = [NSBundle.mainBundle pathForResource:@"tap-fuzzy" ofType:@"aif"]; 31 | [[UISegmentedControl appearance] addSoundWithContentsOfFile:soundBFilePath forControlEvents:UIControlEventValueChanged]; 32 | 33 | NSString *soundCFilePath = [NSBundle.mainBundle pathForResource:@"slide-rock" ofType:@"aif"]; 34 | [[UISwitch appearance] addSoundWithContentsOfFile:soundCFilePath forControlEvents:UIControlEventValueChanged]; 35 | 36 | [[UITextField appearance] addSoundWithContentsOfFile:soundAFilePath forControlEvents:UIControlEventEditingChanged]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #UIControl+Sound 2 | 3 | A simple UIControl category for adding sounds to UI controls such as UIButton, UISwitch, UISegmentedControl, UITextField, etc. 4 | 5 | ##What can it do? 6 | 7 | With this simple category. You can easily add sounds to all (or just one) of the buttons, switches, text fields, I mean UIControls, in your app, with just **[one line of code](#whats-the-one-line-of-code)**. 8 | 9 | ##What's included? 10 | 11 | 3 methods. Simple. Self-explanatory. 12 | 13 | ``` 14 | @interface UIControl (SoundForControlEvents) 15 | 16 | - (void)addSoundWithContentsOfFile:(NSString *)soundFilePath forControlEvents:(UIControlEvents)controlEvents UI_APPEARANCE_SELECTOR; 17 | 18 | - (void)removeSoundWithContentsOfFile:(NSString *)soundFilePath forControlEvents:(UIControlEvents)controlEvents UI_APPEARANCE_SELECTOR; 19 | 20 | // Remove all added sounds for particular event. 21 | - (void)removeSoundsForControlEvents:(UIControlEvents)controlEvents UI_APPEARANCE_SELECTOR; 22 | 23 | @end 24 | ``` 25 | 26 | ##What's the one line of code? 27 | 28 | We use `UIAppearance` to add sound for all of our controls. 29 | 30 | For example, you want to add a tap sound for all of the buttons in your app, and the sound file is named `TapSound.aif` 31 | 32 | ``` 33 | //Call this after your app launches. 34 | [[UIButton appearance] addSoundWithContentsOfFile:[NSBundle.mainBundle pathForResource:@"TapSound" ofType:@"aif"] forControlEvents:UIControlEventTouchUpInside]; 35 | ``` 36 | 37 | Of course, you can just add the tap sound for one button 38 | 39 | ``` 40 | [aButton addSoundWithContentsOfFile:[NSBundle.mainBundle pathForResource:@"TapSound" ofType:@"aif"] forControlEvents:UIControlEventTouchUpInside]; 41 | ``` 42 | 43 | Got it? 44 | 45 | There's also a demo project `UIControlSoundDemo`, you can find the _"Add Sound Code"_ in the `AppDelegate.m` file of the demo project. 46 | 47 | The sound files used in the demo project came from the [Free UI Sound Library - OCTAVE](https://github.com/scopegate/octave). 48 | 49 | ##How does it work? 50 | 51 | It's a little hard to explain what happened underneath. You may have to look into the code. 52 | 53 | The key here is the `WUUIControlSoundManager` class. It's a singleton, and has only one public method. 54 | 55 | ``` 56 | - (SEL)selectorForPlayingSoundFileAtPath:(NSString *)soundFilePath; 57 | ``` 58 | 59 | This method returns a selector. If you make the `WUUIControlSoundManager` perform this selector, it will play the sound at `soundFilePath`. 60 | 61 | --- 62 | 63 | The basic idea here is that `WUUIControlSoundManager` takes that `soundFilePath` and maps it to a selector. 64 | 65 | When `WUUIControlSoundManager` received a message, it will check and see if the message's selector is the selector that can play a sound and what sound it should play, then forward the message to `- (void)playSoundWithIdentifier:(NSString *)soundIdentifier`. 66 | 67 | It looks a little tricky and involves message forwarding. But it's actually not bad, we've created such a simple and solid interface to accomplish a "not so simple" job, while did not mess up anything :) 68 | 69 | ##Requirements 70 | 71 | - AudioToolbox.framework 72 | - Automatic Reference Counting (ARC) 73 | - iOS 5.0+ 74 | - Xcode 4.5+ 75 | 76 | ##Contributing 77 | 78 | If you find a bug and know exactly how to fix it, please open a pull request. 79 | 80 | If you can't make the change yourself, please open an issue after making sure that one isn't already logged. 81 | 82 | ##License 83 | 84 | The MIT license, as aways. 85 | -------------------------------------------------------------------------------- /UIControl+SoundForControlEvents.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIControl+SoundForControlEvents.m 3 | // 4 | // Created by YuAo on 3/2/13. 5 | // Copyright (c) 2013 YuAo. All rights reserved. 6 | // 7 | 8 | #import "UIControl+SoundForControlEvents.h" 9 | 10 | @implementation UIControl (SoundForControlEvents) 11 | 12 | - (void)addSoundWithContentsOfFile:(NSString *)soundFilePath forControlEvents:(UIControlEvents)controlEvents { 13 | if (soundFilePath.length) [self addTarget:WUUIControlSoundManager.sharedSoundManager action:[WUUIControlSoundManager.sharedSoundManager selectorForPlayingSoundFileAtPath:soundFilePath] forControlEvents:controlEvents]; 14 | } 15 | 16 | - (void)removeSoundWithContentsOfFile:(NSString *)soundFilePath forControlEvents:(UIControlEvents)controlEvents { 17 | if (soundFilePath.length) [self removeTarget:WUUIControlSoundManager.sharedSoundManager action:[WUUIControlSoundManager.sharedSoundManager selectorForPlayingSoundFileAtPath:soundFilePath] forControlEvents:controlEvents]; 18 | } 19 | 20 | - (void)removeSoundsForControlEvents:(UIControlEvents)controlEvents { 21 | NSArray *playSoundActions = [self actionsForTarget:WUUIControlSoundManager.sharedSoundManager forControlEvent:controlEvents]; 22 | [playSoundActions enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { 23 | [self removeTarget:WUUIControlSoundManager.sharedSoundManager action:NSSelectorFromString(obj) forControlEvents:controlEvents]; 24 | }]; 25 | } 26 | 27 | @end 28 | 29 | 30 | void WUUIControlSoundManagerAudioServicesSystemSoundCompletionProc (SystemSoundID soundID, void *clientData) { 31 | AudioServicesDisposeSystemSoundID(soundID); 32 | } 33 | 34 | NSString * const WUUIControlSoundManagerPlaySoundSelectorPrefix = @"playSound_"; 35 | 36 | @interface WUUIControlSoundManager() 37 | @property (nonatomic,strong) NSMutableArray *soundFiles; 38 | @end 39 | 40 | @implementation WUUIControlSoundManager 41 | 42 | + (instancetype)sharedSoundManager { 43 | static id _sharedSoundManager = nil; 44 | static dispatch_once_t onceToken; 45 | dispatch_once(&onceToken, ^{ 46 | _sharedSoundManager = [[self.class alloc] init]; 47 | }); 48 | return _sharedSoundManager; 49 | } 50 | 51 | - (NSMutableArray *)soundFiles { 52 | if (!_soundFiles) _soundFiles = [NSMutableArray array]; 53 | return _soundFiles; 54 | } 55 | 56 | - (SEL)selectorForPlayingSoundFileAtPath:(NSString *)soundFilePath { 57 | NSParameterAssert(soundFilePath); 58 | NSString *soundIdentifier = [self soundIdentifierForSoundFile:soundFilePath]; 59 | return NSSelectorFromString([WUUIControlSoundManagerPlaySoundSelectorPrefix stringByAppendingString:soundIdentifier]); 60 | } 61 | 62 | - (NSString *)soundIdentifierForSoundFile:(NSString *)filePath { 63 | if (![self.soundFiles containsObject:filePath]) { 64 | [self.soundFiles addObject:filePath]; 65 | } 66 | return [NSString stringWithFormat:@"%lx",(unsigned long)filePath.hash]; 67 | } 68 | 69 | - (void)playSoundWithIdentifier:(NSString *)soundIdentifier { 70 | NSString *__block soundFileToPlay = nil; 71 | [self.soundFiles enumerateObjectsUsingBlock:^(NSString *soundFilePath, NSUInteger idx, BOOL *stop) { 72 | if ([soundIdentifier isEqualToString:[self soundIdentifierForSoundFile:soundFilePath]]) { 73 | soundFileToPlay = soundFilePath; 74 | } 75 | }]; 76 | if (soundFileToPlay) { 77 | NSURL *filePath = [NSURL fileURLWithPath:soundFileToPlay]; 78 | SystemSoundID sound; 79 | AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &sound); 80 | CFStringRef currentRunLoopMode = CFRunLoopCopyCurrentMode(CFRunLoopGetCurrent()); 81 | AudioServicesAddSystemSoundCompletion(sound, NULL, currentRunLoopMode, &WUUIControlSoundManagerAudioServicesSystemSoundCompletionProc, NULL); 82 | CFRelease(currentRunLoopMode); 83 | AudioServicesPlaySystemSound(sound); 84 | } 85 | } 86 | 87 | - (void)playSound_xxxxx { 88 | //Just a placeholder method. 89 | return; 90 | } 91 | 92 | - (NSString *)soundIdentifierFromSelector:(SEL)selector;{ 93 | NSString *selectorString = NSStringFromSelector(selector); 94 | if([selectorString hasPrefix:WUUIControlSoundManagerPlaySoundSelectorPrefix]){ 95 | NSString *soundIdentifier = [selectorString stringByReplacingOccurrencesOfString:WUUIControlSoundManagerPlaySoundSelectorPrefix withString:@""]; 96 | if (soundIdentifier.length) { 97 | return soundIdentifier; 98 | } 99 | } 100 | return nil; 101 | } 102 | 103 | - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector { 104 | NSMethodSignature *signature = [super methodSignatureForSelector:aSelector]; 105 | if (!signature) { 106 | if ([self soundIdentifierFromSelector:aSelector]) { 107 | signature = [self methodSignatureForSelector:@selector(playSound_xxxxx)]; 108 | } 109 | } 110 | return signature; 111 | } 112 | 113 | - (void)forwardInvocation:(NSInvocation *)anInvocation { 114 | NSString *soundIdentifier = [self soundIdentifierFromSelector:anInvocation.selector]; 115 | if (soundIdentifier) { 116 | [self playSoundWithIdentifier:soundIdentifier]; 117 | } else { 118 | [super forwardInvocation:anInvocation]; 119 | } 120 | } 121 | 122 | @end -------------------------------------------------------------------------------- /UIControlSoundDemo/UIControlSoundDemo/DemoViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1552 5 | 12C60 6 | 3084 7 | 1187.34 8 | 625.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 2083 12 | 13 | 14 | IBProxyObject 15 | IBUIButton 16 | IBUISegmentedControl 17 | IBUISwitch 18 | IBUITextField 19 | IBUIView 20 | 21 | 22 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 23 | 24 | 25 | PluginDependencyRecalculationVersion 26 | 27 | 28 | 29 | 30 | IBFilesOwner 31 | IBCocoaTouchFramework 32 | 33 | 34 | IBFirstResponder 35 | IBCocoaTouchFramework 36 | 37 | 38 | 39 | 274 40 | 41 | 42 | 43 | 292 44 | {{80, 34}, {73, 44}} 45 | 46 | 47 | _NS:9 48 | NO 49 | IBCocoaTouchFramework 50 | 0 51 | 0 52 | 1 53 | Button 54 | 55 | 3 56 | MQA 57 | 58 | 59 | 1 60 | MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA 61 | 62 | 63 | 3 64 | MC41AA 65 | 66 | 67 | 2 68 | 15 69 | 70 | 71 | Helvetica-Bold 72 | 15 73 | 16 74 | 75 | 76 | 77 | 78 | 292 79 | {{80, 104}, {161, 44}} 80 | 81 | 82 | _NS:9 83 | NO 84 | IBCocoaTouchFramework 85 | 2 86 | 0 87 | 88 | First 89 | Second 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | {0, 0} 101 | {0, 0} 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 292 111 | {{149, 42}, {94, 27}} 112 | 113 | 114 | _NS:9 115 | NO 116 | IBCocoaTouchFramework 117 | 0 118 | 0 119 | YES 120 | 121 | 122 | 123 | 292 124 | {{80, 176}, {161, 30}} 125 | 126 | 127 | _NS:9 128 | NO 129 | YES 130 | IBCocoaTouchFramework 131 | 0 132 | 133 | 3 134 | 135 | 3 136 | MAA 137 | 138 | 2 139 | 140 | 141 | YES 142 | 17 143 | 144 | IBCocoaTouchFramework 145 | 146 | 147 | 1 148 | 14 149 | 150 | 151 | Helvetica 152 | 14 153 | 16 154 | 155 | 156 | 157 | {{0, 20}, {320, 548}} 158 | 159 | 160 | 161 | 3 162 | MQA 163 | 164 | 165 | 166 | 167 | IBUIScreenMetrics 168 | 169 | YES 170 | 171 | 172 | 173 | 174 | 175 | {320, 568} 176 | {568, 320} 177 | 178 | 179 | IBCocoaTouchFramework 180 | Retina 4 Full Screen 181 | 2 182 | 183 | IBCocoaTouchFramework 184 | 185 | 186 | 187 | 188 | 189 | 190 | view 191 | 192 | 193 | 194 | 3 195 | 196 | 197 | 198 | 199 | 200 | 0 201 | 202 | 203 | 204 | 205 | 206 | 1 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | -1 218 | 219 | 220 | File's Owner 221 | 222 | 223 | -2 224 | 225 | 226 | 227 | 228 | 4 229 | 230 | 231 | 232 | 233 | 7 234 | 235 | 236 | 237 | 238 | 19 239 | 240 | 241 | 242 | 243 | 20 244 | 245 | 246 | 247 | 248 | 249 | 250 | DemoViewController 251 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 252 | UIResponder 253 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 254 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 255 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 256 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 257 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 258 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 259 | 260 | 261 | 262 | 263 | 264 | 20 265 | 266 | 267 | 268 | 269 | DemoViewController 270 | UIViewController 271 | 272 | IBProjectSource 273 | ./Classes/DemoViewController.h 274 | 275 | 276 | 277 | 278 | 0 279 | IBCocoaTouchFramework 280 | YES 281 | 3 282 | 2083 283 | 284 | 285 | -------------------------------------------------------------------------------- /UIControlSoundDemo/UIControlSoundDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9D0391F316E1DA410000631B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9D0391F216E1DA410000631B /* UIKit.framework */; }; 11 | 9D0391F516E1DA410000631B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9D0391F416E1DA410000631B /* Foundation.framework */; }; 12 | 9D0391F716E1DA410000631B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9D0391F616E1DA410000631B /* CoreGraphics.framework */; }; 13 | 9D0391FD16E1DA410000631B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 9D0391FB16E1DA410000631B /* InfoPlist.strings */; }; 14 | 9D0391FF16E1DA410000631B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D0391FE16E1DA410000631B /* main.m */; }; 15 | 9D03920316E1DA410000631B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D03920216E1DA410000631B /* AppDelegate.m */; }; 16 | 9D03920516E1DA410000631B /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 9D03920416E1DA410000631B /* Default.png */; }; 17 | 9D03920716E1DA410000631B /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9D03920616E1DA410000631B /* Default@2x.png */; }; 18 | 9D03920916E1DA410000631B /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9D03920816E1DA410000631B /* Default-568h@2x.png */; }; 19 | 9D03921816E1DA5F0000631B /* DemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D03921616E1DA5F0000631B /* DemoViewController.m */; }; 20 | 9D03921916E1DA5F0000631B /* DemoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9D03921716E1DA5F0000631B /* DemoViewController.xib */; }; 21 | 9D03922016E1DC630000631B /* UIControl+SoundForControlEvents.m in Sources */ = {isa = PBXBuildFile; fileRef = 9D03921F16E1DC630000631B /* UIControl+SoundForControlEvents.m */; }; 22 | 9D03922216E1DC880000631B /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9D03922116E1DC880000631B /* AudioToolbox.framework */; }; 23 | 9D03922F16E1DE760000631B /* tap-fuzzy.aif in Resources */ = {isa = PBXBuildFile; fileRef = 9D03922B16E1DE760000631B /* tap-fuzzy.aif */; }; 24 | 9D03923416E1DECD0000631B /* tap-kissy.aif in Resources */ = {isa = PBXBuildFile; fileRef = 9D03923116E1DECD0000631B /* tap-kissy.aif */; }; 25 | 9D03923816E1DF760000631B /* slide-rock.aif in Resources */ = {isa = PBXBuildFile; fileRef = 9D03923716E1DF760000631B /* slide-rock.aif */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | 9D0391EF16E1DA410000631B /* UIControlSoundDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UIControlSoundDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | 9D0391F216E1DA410000631B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 31 | 9D0391F416E1DA410000631B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 32 | 9D0391F616E1DA410000631B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 33 | 9D0391FA16E1DA410000631B /* UIControlSoundDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "UIControlSoundDemo-Info.plist"; sourceTree = ""; }; 34 | 9D0391FC16E1DA410000631B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 35 | 9D0391FE16E1DA410000631B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 36 | 9D03920016E1DA410000631B /* UIControlSoundDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIControlSoundDemo-Prefix.pch"; sourceTree = ""; }; 37 | 9D03920116E1DA410000631B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 38 | 9D03920216E1DA410000631B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 39 | 9D03920416E1DA410000631B /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 40 | 9D03920616E1DA410000631B /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 41 | 9D03920816E1DA410000631B /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 42 | 9D03921516E1DA5F0000631B /* DemoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoViewController.h; sourceTree = ""; }; 43 | 9D03921616E1DA5F0000631B /* DemoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoViewController.m; sourceTree = ""; }; 44 | 9D03921716E1DA5F0000631B /* DemoViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DemoViewController.xib; sourceTree = ""; }; 45 | 9D03921E16E1DC630000631B /* UIControl+SoundForControlEvents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIControl+SoundForControlEvents.h"; path = "../../UIControl+SoundForControlEvents.h"; sourceTree = ""; }; 46 | 9D03921F16E1DC630000631B /* UIControl+SoundForControlEvents.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIControl+SoundForControlEvents.m"; path = "../../UIControl+SoundForControlEvents.m"; sourceTree = ""; }; 47 | 9D03922116E1DC880000631B /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 48 | 9D03922B16E1DE760000631B /* tap-fuzzy.aif */ = {isa = PBXFileReference; lastKnownFileType = file; path = "tap-fuzzy.aif"; sourceTree = ""; }; 49 | 9D03923116E1DECD0000631B /* tap-kissy.aif */ = {isa = PBXFileReference; lastKnownFileType = file; path = "tap-kissy.aif"; sourceTree = ""; }; 50 | 9D03923716E1DF760000631B /* slide-rock.aif */ = {isa = PBXFileReference; lastKnownFileType = file; path = "slide-rock.aif"; sourceTree = ""; }; 51 | /* End PBXFileReference section */ 52 | 53 | /* Begin PBXFrameworksBuildPhase section */ 54 | 9D0391EC16E1DA410000631B /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 2147483647; 57 | files = ( 58 | 9D03922216E1DC880000631B /* AudioToolbox.framework in Frameworks */, 59 | 9D0391F316E1DA410000631B /* UIKit.framework in Frameworks */, 60 | 9D0391F516E1DA410000631B /* Foundation.framework in Frameworks */, 61 | 9D0391F716E1DA410000631B /* CoreGraphics.framework in Frameworks */, 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | /* End PBXFrameworksBuildPhase section */ 66 | 67 | /* Begin PBXGroup section */ 68 | 9D0391E616E1DA410000631B = { 69 | isa = PBXGroup; 70 | children = ( 71 | 9D0391F816E1DA410000631B /* UIControlSoundDemo */, 72 | 9D0391F116E1DA410000631B /* Frameworks */, 73 | 9D0391F016E1DA410000631B /* Products */, 74 | ); 75 | sourceTree = ""; 76 | }; 77 | 9D0391F016E1DA410000631B /* Products */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | 9D0391EF16E1DA410000631B /* UIControlSoundDemo.app */, 81 | ); 82 | name = Products; 83 | sourceTree = ""; 84 | }; 85 | 9D0391F116E1DA410000631B /* Frameworks */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | 9D03922116E1DC880000631B /* AudioToolbox.framework */, 89 | 9D0391F216E1DA410000631B /* UIKit.framework */, 90 | 9D0391F416E1DA410000631B /* Foundation.framework */, 91 | 9D0391F616E1DA410000631B /* CoreGraphics.framework */, 92 | ); 93 | name = Frameworks; 94 | sourceTree = ""; 95 | }; 96 | 9D0391F816E1DA410000631B /* UIControlSoundDemo */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 9D03920116E1DA410000631B /* AppDelegate.h */, 100 | 9D03920216E1DA410000631B /* AppDelegate.m */, 101 | 9D03921E16E1DC630000631B /* UIControl+SoundForControlEvents.h */, 102 | 9D03921F16E1DC630000631B /* UIControl+SoundForControlEvents.m */, 103 | 9D03921D16E1DC010000631B /* DemoUI */, 104 | 9D03921A16E1DBEF0000631B /* Resources */, 105 | 9D0391F916E1DA410000631B /* Supporting Files */, 106 | ); 107 | path = UIControlSoundDemo; 108 | sourceTree = ""; 109 | }; 110 | 9D0391F916E1DA410000631B /* Supporting Files */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 9D0391FA16E1DA410000631B /* UIControlSoundDemo-Info.plist */, 114 | 9D0391FB16E1DA410000631B /* InfoPlist.strings */, 115 | 9D0391FE16E1DA410000631B /* main.m */, 116 | 9D03920016E1DA410000631B /* UIControlSoundDemo-Prefix.pch */, 117 | 9D03920416E1DA410000631B /* Default.png */, 118 | 9D03920616E1DA410000631B /* Default@2x.png */, 119 | 9D03920816E1DA410000631B /* Default-568h@2x.png */, 120 | ); 121 | name = "Supporting Files"; 122 | sourceTree = ""; 123 | }; 124 | 9D03921A16E1DBEF0000631B /* Resources */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 9D03923116E1DECD0000631B /* tap-kissy.aif */, 128 | 9D03923716E1DF760000631B /* slide-rock.aif */, 129 | 9D03922B16E1DE760000631B /* tap-fuzzy.aif */, 130 | ); 131 | path = Resources; 132 | sourceTree = ""; 133 | }; 134 | 9D03921D16E1DC010000631B /* DemoUI */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 9D03921516E1DA5F0000631B /* DemoViewController.h */, 138 | 9D03921616E1DA5F0000631B /* DemoViewController.m */, 139 | 9D03921716E1DA5F0000631B /* DemoViewController.xib */, 140 | ); 141 | name = DemoUI; 142 | sourceTree = ""; 143 | }; 144 | /* End PBXGroup section */ 145 | 146 | /* Begin PBXNativeTarget section */ 147 | 9D0391EE16E1DA410000631B /* UIControlSoundDemo */ = { 148 | isa = PBXNativeTarget; 149 | buildConfigurationList = 9D03921216E1DA410000631B /* Build configuration list for PBXNativeTarget "UIControlSoundDemo" */; 150 | buildPhases = ( 151 | 9D0391EB16E1DA410000631B /* Sources */, 152 | 9D0391EC16E1DA410000631B /* Frameworks */, 153 | 9D0391ED16E1DA410000631B /* Resources */, 154 | ); 155 | buildRules = ( 156 | ); 157 | dependencies = ( 158 | ); 159 | name = UIControlSoundDemo; 160 | productName = UIControlSoundDemo; 161 | productReference = 9D0391EF16E1DA410000631B /* UIControlSoundDemo.app */; 162 | productType = "com.apple.product-type.application"; 163 | }; 164 | /* End PBXNativeTarget section */ 165 | 166 | /* Begin PBXProject section */ 167 | 9D0391E716E1DA410000631B /* Project object */ = { 168 | isa = PBXProject; 169 | attributes = { 170 | LastUpgradeCheck = 0460; 171 | ORGANIZATIONNAME = YuAo; 172 | }; 173 | buildConfigurationList = 9D0391EA16E1DA410000631B /* Build configuration list for PBXProject "UIControlSoundDemo" */; 174 | compatibilityVersion = "Xcode 3.2"; 175 | developmentRegion = English; 176 | hasScannedForEncodings = 0; 177 | knownRegions = ( 178 | en, 179 | ); 180 | mainGroup = 9D0391E616E1DA410000631B; 181 | productRefGroup = 9D0391F016E1DA410000631B /* Products */; 182 | projectDirPath = ""; 183 | projectRoot = ""; 184 | targets = ( 185 | 9D0391EE16E1DA410000631B /* UIControlSoundDemo */, 186 | ); 187 | }; 188 | /* End PBXProject section */ 189 | 190 | /* Begin PBXResourcesBuildPhase section */ 191 | 9D0391ED16E1DA410000631B /* Resources */ = { 192 | isa = PBXResourcesBuildPhase; 193 | buildActionMask = 2147483647; 194 | files = ( 195 | 9D0391FD16E1DA410000631B /* InfoPlist.strings in Resources */, 196 | 9D03920516E1DA410000631B /* Default.png in Resources */, 197 | 9D03920716E1DA410000631B /* Default@2x.png in Resources */, 198 | 9D03920916E1DA410000631B /* Default-568h@2x.png in Resources */, 199 | 9D03921916E1DA5F0000631B /* DemoViewController.xib in Resources */, 200 | 9D03922F16E1DE760000631B /* tap-fuzzy.aif in Resources */, 201 | 9D03923416E1DECD0000631B /* tap-kissy.aif in Resources */, 202 | 9D03923816E1DF760000631B /* slide-rock.aif in Resources */, 203 | ); 204 | runOnlyForDeploymentPostprocessing = 0; 205 | }; 206 | /* End PBXResourcesBuildPhase section */ 207 | 208 | /* Begin PBXSourcesBuildPhase section */ 209 | 9D0391EB16E1DA410000631B /* Sources */ = { 210 | isa = PBXSourcesBuildPhase; 211 | buildActionMask = 2147483647; 212 | files = ( 213 | 9D0391FF16E1DA410000631B /* main.m in Sources */, 214 | 9D03920316E1DA410000631B /* AppDelegate.m in Sources */, 215 | 9D03921816E1DA5F0000631B /* DemoViewController.m in Sources */, 216 | 9D03922016E1DC630000631B /* UIControl+SoundForControlEvents.m in Sources */, 217 | ); 218 | runOnlyForDeploymentPostprocessing = 0; 219 | }; 220 | /* End PBXSourcesBuildPhase section */ 221 | 222 | /* Begin PBXVariantGroup section */ 223 | 9D0391FB16E1DA410000631B /* InfoPlist.strings */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | 9D0391FC16E1DA410000631B /* en */, 227 | ); 228 | name = InfoPlist.strings; 229 | sourceTree = ""; 230 | }; 231 | /* End PBXVariantGroup section */ 232 | 233 | /* Begin XCBuildConfiguration section */ 234 | 9D03921016E1DA410000631B /* Debug */ = { 235 | isa = XCBuildConfiguration; 236 | buildSettings = { 237 | ALWAYS_SEARCH_USER_PATHS = NO; 238 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 239 | CLANG_CXX_LIBRARY = "libc++"; 240 | CLANG_ENABLE_OBJC_ARC = YES; 241 | CLANG_WARN_CONSTANT_CONVERSION = YES; 242 | CLANG_WARN_EMPTY_BODY = YES; 243 | CLANG_WARN_ENUM_CONVERSION = YES; 244 | CLANG_WARN_INT_CONVERSION = YES; 245 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 246 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 247 | COPY_PHASE_STRIP = NO; 248 | GCC_C_LANGUAGE_STANDARD = gnu99; 249 | GCC_DYNAMIC_NO_PIC = NO; 250 | GCC_OPTIMIZATION_LEVEL = 0; 251 | GCC_PREPROCESSOR_DEFINITIONS = ( 252 | "DEBUG=1", 253 | "$(inherited)", 254 | ); 255 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 256 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 257 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 258 | GCC_WARN_UNUSED_VARIABLE = YES; 259 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 260 | ONLY_ACTIVE_ARCH = YES; 261 | SDKROOT = iphoneos; 262 | }; 263 | name = Debug; 264 | }; 265 | 9D03921116E1DA410000631B /* Release */ = { 266 | isa = XCBuildConfiguration; 267 | buildSettings = { 268 | ALWAYS_SEARCH_USER_PATHS = NO; 269 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 270 | CLANG_CXX_LIBRARY = "libc++"; 271 | CLANG_ENABLE_OBJC_ARC = YES; 272 | CLANG_WARN_CONSTANT_CONVERSION = YES; 273 | CLANG_WARN_EMPTY_BODY = YES; 274 | CLANG_WARN_ENUM_CONVERSION = YES; 275 | CLANG_WARN_INT_CONVERSION = YES; 276 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 277 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 278 | COPY_PHASE_STRIP = YES; 279 | GCC_C_LANGUAGE_STANDARD = gnu99; 280 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 281 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 282 | GCC_WARN_UNUSED_VARIABLE = YES; 283 | IPHONEOS_DEPLOYMENT_TARGET = 6.1; 284 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 285 | SDKROOT = iphoneos; 286 | VALIDATE_PRODUCT = YES; 287 | }; 288 | name = Release; 289 | }; 290 | 9D03921316E1DA410000631B /* Debug */ = { 291 | isa = XCBuildConfiguration; 292 | buildSettings = { 293 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 294 | GCC_PREFIX_HEADER = "UIControlSoundDemo/UIControlSoundDemo-Prefix.pch"; 295 | INFOPLIST_FILE = "UIControlSoundDemo/UIControlSoundDemo-Info.plist"; 296 | PRODUCT_NAME = "$(TARGET_NAME)"; 297 | WRAPPER_EXTENSION = app; 298 | }; 299 | name = Debug; 300 | }; 301 | 9D03921416E1DA410000631B /* Release */ = { 302 | isa = XCBuildConfiguration; 303 | buildSettings = { 304 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 305 | GCC_PREFIX_HEADER = "UIControlSoundDemo/UIControlSoundDemo-Prefix.pch"; 306 | INFOPLIST_FILE = "UIControlSoundDemo/UIControlSoundDemo-Info.plist"; 307 | PRODUCT_NAME = "$(TARGET_NAME)"; 308 | WRAPPER_EXTENSION = app; 309 | }; 310 | name = Release; 311 | }; 312 | /* End XCBuildConfiguration section */ 313 | 314 | /* Begin XCConfigurationList section */ 315 | 9D0391EA16E1DA410000631B /* Build configuration list for PBXProject "UIControlSoundDemo" */ = { 316 | isa = XCConfigurationList; 317 | buildConfigurations = ( 318 | 9D03921016E1DA410000631B /* Debug */, 319 | 9D03921116E1DA410000631B /* Release */, 320 | ); 321 | defaultConfigurationIsVisible = 0; 322 | defaultConfigurationName = Release; 323 | }; 324 | 9D03921216E1DA410000631B /* Build configuration list for PBXNativeTarget "UIControlSoundDemo" */ = { 325 | isa = XCConfigurationList; 326 | buildConfigurations = ( 327 | 9D03921316E1DA410000631B /* Debug */, 328 | 9D03921416E1DA410000631B /* Release */, 329 | ); 330 | defaultConfigurationIsVisible = 0; 331 | defaultConfigurationName = Release; 332 | }; 333 | /* End XCConfigurationList section */ 334 | }; 335 | rootObject = 9D0391E716E1DA410000631B /* Project object */; 336 | } 337 | --------------------------------------------------------------------------------