How to make your iPhone vibrate
Done with only one line of code:
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
You need to import the AudioToolbox Framework and import it in your header file for this to work.
Done with only one line of code:
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
You need to import the AudioToolbox Framework and import it in your header file for this to work.
Just like playing a standard sound file, you can also choose to play an alert. The difference is that this will make the iPhone vibrate if it’s set to silent. The code is nearly identical to the standard sound file with the exception of the very last line of code: SystemSoundID soundID; NSString *soundFile = […]
This is a rather cryptic setup, but here’s how it works: SystemSoundID soundID; NSString *soundFile = [[NSBundle mainBundle]pathForResource:@”yourfile” ofType:@”wav”]; AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:soundFile], &soundID); AudioServicesPlaySystemSound(soundID); This snippet assumes you’re using a file called yourfile.wav which needs to present in your project. You’ll also need to import the AudioToolbox Framework and import it in your header file.
Here’s how we can create a simple pop-up window via the UIAlertView instance. It can have a title, some info text and several buttons (OK, Cancel, etc). We’ll only deal with one button and not worry about how to read out which button value has been pressed. And here’s how we build this on Objective-C: […]
Here’s how you load data you’ve previously saved with NSUserDefaults. Since you only load data once I’d put this in the AppDelegate.m file (as applicationDidFinishLaunching) or in ViewDidLoad if you have a single view application: // let’s load our data if there is any NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; int theNumber = [defaults integerForKey:@”theNumber”]; NSString […]
There are several ways to save and retrieve data for persistent storage (i.e. when you close your app and open it again). This is the easiest one I can think of: NSUserDefaults. Here’s an example that saves a text field from an IBOutlet. We’re saving both a string and an integer. We can use this […]
While you’re in info.plist, go to the bottom of the list and add an item (right-click on the empty space and select “Add Row”). Then call it UIPrerenderedIcon. Now the item changes into “Icon already includes gloss effect”, giving you the option to select YES or NO (NO means gloss is switched on, YES means […]
Find the info.plist file (in the Supporting Files folder). Say your app is called MyApp, then you’re looking for a file called MyApp-info.plist Say hello to a scary list of key/value pairs In here, find the Bundle Display Name Change it from the default ${PRODUCT_NAME} to your title Build and see your title underneath your […]