[NSThread sleepForTimeInterval:1.0];
2014年5月25日日曜日
2014年5月16日金曜日
iTunesとのファイル共有の設定
iTunesのAppのファイル共有でファイルを転送できるようにするには、info.plistを以下のように設定する。
Application supports iTunes file sharing : YES
Application supports iTunes file sharing : YES
2014年5月14日水曜日
Documentsディレクトリの取得
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0];
2014年5月1日木曜日
アプリアイコンの光沢を消す
iOS7ではデフォルトでアプリアイコンの光沢(グロス)はついていない。
xcassetsを使用する場合で、iOS6以前のアプリアイコンの光沢(グロス)を消す場合は、
XcodeでxcassetsのAppIconを選択し、右側のAttributes inspectorを表示して iOS icon is pre-rendered にチェックを入れて、一旦クリーンしてビルドし直す。
xcassetsを使用しない場合は、info.plistで Icon already includes gloss effects を YES に設定する。
xcassetsを使用する場合で、iOS6以前のアプリアイコンの光沢(グロス)を消す場合は、
XcodeでxcassetsのAppIconを選択し、右側のAttributes inspectorを表示して iOS icon is pre-rendered にチェックを入れて、一旦クリーンしてビルドし直す。
xcassetsを使用しない場合は、info.plistで Icon already includes gloss effects を YES に設定する。
2014年4月30日水曜日
Retinaディスプレイの判定
Retinaディスプレイかどうかの判定には、[UIScreen mainScreen].scale の値を見る。
if ([UIScreen mainScreen].scale == 2.0) { // retinaディスプレイ }
2014年4月19日土曜日
SLComposeViewControllerを使用したTwitter, Facebook投稿
プロジェクトにSocial.framework を追加する。
Social.hをインポートする。
・Twitter投稿の場合
SLComposeViewControllerでTwitter投稿画面を表示する。
iOS6.Xでは入れないと投稿後の画面操作ができなくなる。
・Facebook投稿の場合
SLComposeViewControllerでFacebook投稿画面を表示する。
Social.hをインポートする。
・Twitter投稿の場合
SLComposeViewControllerでTwitter投稿画面を表示する。
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { SLComposeViewController *composeVC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; // CompletionHandlerを設定 [composeVC setCompletionHandler:^(SLComposeViewControllerResult result) { [self dismissViewControllerAnimated:YES completion:nil]; if (result == SLComposeViewControllerResultDone) { NSLog(@"sendTwitter success"); } }]; // POSTするテキストの初期設定 NSString* message = [NSString stringWithFormat:@"XXXXXXXXXX"]; [composeVC setInitialText:message]; // URLをPOSTする場合 [composeVC addURL:[NSURL URLWithString:@"http://XXXXXXXX"]]; // 画像をPOSTする場合 [composeVC addImage:[UIImage imageNamed:@"XXXXX"]]; // SLComposeViewController表示 [self presentViewController:composeVC animated:YES completion:nil]; }CompletionHandlerに入れたdismissViewControllerAnimatedはiOS7.Xではなくても動いたが、
iOS6.Xでは入れないと投稿後の画面操作ができなくなる。
・Facebook投稿の場合
SLComposeViewControllerでFacebook投稿画面を表示する。
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) { SLComposeViewController *composeVC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; [composeVC setCompletionHandler:^(SLComposeViewControllerResult result) { [self dismissViewControllerAnimated:YES completion:nil]; if (result == SLComposeViewControllerResultDone) { DEBUG_LOG(@"sendFacebook success"); } }]; // POSTするテキストの初期設定 NSString* message = [NSString stringWithFormat:@"XXXXXXXXXX"]; [composeVC setInitialText:message]; // URLをPOSTする場合 [composeVC addURL:[NSURL URLWithString:@"http://XXXXXXXX"]]; // 画像をPOSTする場合 [composeVC addImage:[UIImage imageNamed:@"XXXXX"]]; // SLComposeViewController表示 [self presentViewController:composeVC animated:YES completion:nil]; }CompletionHandlerに入れたdismissViewControllerAnimatedはなくても動く。
2014年4月13日日曜日
デバイスの情報を取得する
[UIDevice currentDevice]からOSバージョンやiPadかiPhoneか等、デバイスの情報を取得する。
デバイスのUDIDはかつては取得できたが、現在は取得できなくなった。
※identifierForVendorはデバイス上の対象ベンダーのアプリ全てを削除して、再インストールすると別IDになる。
デバイスのUDIDはかつては取得できたが、現在は取得できなくなった。
// 名称 NSLog(@"name[%@]", [UIDevice currentDevice].name); // OS名 NSLog(@"systemName[%@]", [UIDevice currentDevice].systemName); // OSバージョン NSLog(@"systemVersion[%@]", [UIDevice currentDevice].systemVersion); // デバイスのモデル NSLog(@"model[%@]", [UIDevice currentDevice].model); NSLog(@"localizedModel[%@]", [UIDevice currentDevice].localizedModel); // デバイスのインターフェースタイプ(iPhoneかiPadか) // UIUserInterfaceIdiomPhone, UIUserInterfaceIdiomPad if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) { NSLog(@"userInterfaceIdiom is iPad"); } else if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) { NSLog(@"userInterfaceIdiom is iPhone"); } // アプリのベンダー毎のUUID NSLog(@"identifierForVendor[%@]", [UIDevice currentDevice].identifierForVendor);
2014-04-13 13:42:21.503 Device[5307:60b] name[XXXのiPad] 2014-04-13 13:42:21.505 Device[5307:60b] systemName[iPhone OS] 2014-04-13 13:42:21.506 Device[5307:60b] systemVersion[7.0.6] 2014-04-13 13:42:21.507 Device[5307:60b] model[iPad] 2014-04-13 13:42:21.509 Device[5307:60b] localizedModel[iPad] 2014-04-13 13:42:21.510 Device[5307:60b] userInterfaceIdiom is iPad 2014-04-13 13:42:21.515 Device[5307:60b] identifierForVendor[<__nsconcreteuuid 0x15604e20> D291C209-B5AF-430A-9AC5-66859F0AF1CB]
※identifierForVendorはデバイス上の対象ベンダーのアプリ全てを削除して、再インストールすると別IDになる。
2013年10月16日水曜日
iOSのバージョン判定マクロ
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) #define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
2013年9月26日木曜日
アプリケーションアイコンのサイズ
アプリケーションアイコンのサイズ
iPad 72×72
iPad(retina) 144×144
iPhone 57×57
iPhone(retina) 114×114
iPad 72×72
iPad(retina) 144×144
iPhone 57×57
iPhone(retina) 114×114
2013年9月4日水曜日
blockの外の変数をblock内で変更するときは__blockをつける
block外で宣言した変数をblock内で変更するときは、__block をつけて宣言する。
__block NSInteger i = 0; [indexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) { ... i = ... }
登録:
投稿 (Atom)