Great tutorial on how to implement In App Purchases:
http://www.raywenderlich.com/21081/introduction-to-in-app-purchases-in-ios-6-tutorial
Great tutorial on how to implement In App Purchases:
http://www.raywenderlich.com/21081/introduction-to-in-app-purchases-in-ios-6-tutorial
You can use the backgroundColor property for this:
1 |
self.yourView.backgroundColor = [UIColor purpleColor]; |
Pre-defined values are
You can also define your own colours by creating a UIColor object (from RGB or HSL values). Here’s how you can create your own RGB colour and use it with the above example:
1 2 |
UIColor *myPurple = [[UIColor alloc]initWithRed:1 green:0.5 blue:1 alpha:1]; self.yourView.backgroundColor = myPurple; |
RGB and alpha must be defined as CGFloat numbers, i.e. between 0 and 1. The alpha value is the opacity, so 1 is fully visible and 0 is invisible.
1 2 3 4 5 |
NSDate *date = [NSDate date]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init]; [dateFormatter setDateStyle:NSDateFormatterLongStyle]; [dateFormatter setTimeStyle:NSDateFormatterLongStyle]; NSString *dateString = [dateFormatter stringFromDate:date]; |
First we’ll create a date object. Next we’ll create an NSDateFormatter and set how we’d like for display our date (and optionally our time). Then we’ll call the magical stringFromDate method which will create our string.
The following method will return a two letter code of which language is set on the iOS device in question:
[emember_protected]
1 |
NSString *myLanguage = [[NSLocale preferredLanguages] objectAtIndex:0]; |
There’s a list of language codes on Wikipedia: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
Note that to compare the current value against a list of languages you support we need use the isEqualToString method. Here’s an example:
1 2 3 4 5 6 7 8 9 |
NSString *myLanguage = [[NSLocale preferredLanguages] objectAtIndex:0]; if ([myLanguage isEqualToString:@"de"]) { self.myLabel.text = @"Deutsch"; } else if ([myLanguage isEqualToString:@"en"]) { self.myLabel.text = @"English"; } else { self.myLabel.text = @"didn't work"; } |
[/emember_protected]
The following articles have helped me figure this out:
Before we start we need to create a new file called Localizable.strings (from File – New – Resource – Strings File). Xcode needs one file per language. Next we create localized copies of our files:
[emember_protected]
Xcode will bring up a dialogue box and suggest files it can translate. Leave them all ticked (or uncheck the ones you don’t need) and hit finish.
Notice that Xcode has now created the translated files underneath the original files: Storyboards and Localizable.strings:
Technically with two languages there are only two files – the first one is just a heading to clarify. Prior to 4.4 Xcode would create a separate folder per language (like en.lproj) and add the files there but that’s not the case anymore.
Storyboard files can be translated “by hand”, whereas string files can be translated using key/value pairs in your Localizable.strings file. Here’s an example: to print the text in a label, instead of
1 |
self.myLabel.text = @"English Text"; |
we’d use the following:
1 |
self.myLabel.text = NSLocalizedString(@"myText", nil); |
In a Localizable.strings file for English we define
1 |
"myText" = "English Text"; |
and Xcode (or rather the iPhone) will print out this text when our phone is set to English (under Settings – General – International – Language). In the Localizable.strings file for any other language we can define translations with the same key, for example
1 |
"myText" = "Deutscher Text"; |
This would be displayed when the iPhone is set to German.
[/emember_protected]
You can add other translations to files such as Localizable.strings simply by selecting the file on the left, and then adding a translation on the right hand side under “Localizations” in the File Inspector:
Direct web link to your app or developer account showing all your apps:
Direct link to a country specific app store (say Germany in this exampe):
If your app name contains spaces replace them with dashes. Replace http with imts to avoid Safari redirects on iOS devices. The http links will send web users to a page which asks to open iTunes on their machines.
To link from Objective-C so that the app store app opens automatically:
1 |
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/myappname"]]; |
Alternatively you can use Apple’s Link Maker Tool: http://itunes.apple.com/linkmaker/ – this lets you create buttons like the one below as well as direct links to web pages that look like iTunes: