2013년 10월 17일 목요일

UILabel Auto Font Size Change

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 768, 300)];
    label.font = [UIFont systemFontOfSize:50]; //表示フォントサイズ設定
    label.adjustsFontSizeToFitWidth = YES; //Autoshrink設定をYES
    label.numberOfLines = 2; //2行改行
    label.textAlignment = NSTextAlignmentCenter;//真ん中表示
    label.text = @"あああああああああああああああああああああああああああああああああああああああああああああああ";
    label.minimumScaleFactor = 0.5;//小さくするのをどこまでするかのスケール設定

    

    [_contentView addSubview:label];

2013년 10월 7일 월요일

縦向きの外部ディスプレイでiOSアプリ表示時、全画面にする方法

if ([[UIScreen screens] count] >1) { 
        //スクリーンが2つ以上存在する=外部ディスプレイ有り 
       UIScreen *secondScreen = [[UIScreen screens] objectAtIndex:1];
  secondScreen.overscanCompensation = UIScreenOverscanCompensationInsetApplicationFrame;   →全画面表示オプション     
       UIWindow *secondWindow = [[UIWindow alloc] initWithFrame:[secondScreen bounds]];        
       secondWindow.screen = secondScreen; 
       ViewForSub = [[UIView alloc] initWithFrame:[secondScreen bounds]]; 
       ViewForSub.backgroundColor = [UIColor blackColor];

       //以下、ViewForSubに必要なUI部品をaddSubviewしていく 
       //必要に応じて、ViewForMainにUILabel等を置いて「テレビ画面出力中」などと表示する 
   } else {    
       //外部ディスプレイ無し 
       (以下、ViewForMainに必要なUI部品をaddSubviewしていく)

   }

Youtubeから動画をダウンロードする方法(Chrome編)

****インストール手順(Chromeの場合・引用)****
>  1. 拡張機能ファイル(.crx) を右クリック→"名前を付けて保存"を選択
>  2. chrome://extensions/ を開く(アドレスバーに入力)
>  3. 1 でダウンロードしたファイルを 、2 のページにドラッグ・アンド・ドロップする

2012년 9월 10일 월요일

SVN(SubVersion)リビジョン比較コマンドとリビジョン戻す方法


比較するリビジョン番号が1234と2345の場合以下のURLになります。
svn diff -r 1234: 1234 http://SVN_Address/プロジェクトURL

・リビジョン1234を123を戻す方法は以下となります。
  svn merge -r 1234:1233 http://svn.example.com/repos/agt/trunk
・コミット処理
  svn commit -m "Undoing change committed in r1234."

・1つのファイルのみ戻したい場合は以下となります。
  svn merge -r 7:6 test.m 
・コミット処理
  svn commit -m 'reverted to 6' test.m

2012년 8월 27일 월요일

IOSデータ保護方法

※iOS 4 以降、データ保護機能が提供されるようになりました。
データ保護機能を有効にするにはパスコードロックを有効にする必要がある



【NSFileManager】
NSDictionary* attributes = [NSDictionary dictionaryWithObject:NSFileProtectionComplete forKey:NSFileProtectionKey];
NSError* error = nil;
[fileManager setAttributes:attributes ofItemAtPath:filePath error:&error];


【NSData】
NSError* error = nil;
NSData* data = [NSData dataWithContentsOfFile:src1];
[data writeToFile:filePath options:NSDataWritingFileProtectionComplete error:&error];

2012년 8월 21일 화요일

CoreData データモデル属性













Attribute


【オプション/Option】
オプションにチェックをした場合、Entityは、そのAttributeが値を持たない場合でも保存可能である。逆に、オプションではないAttributeに値がセットされていない状態でEntityを保存しようとするとエラーが返される。
そのAttributeが必須項目であれば、オプションからチェックをはずし、そうでなければチェックしておけばよい。

【一時/Transient】
一時的なAttributeは、生成はされるが、ディスク上(Persistent store)には保存されない。
臨時保存先となります。

【索引付き/Indexed】
索引付きにチェックをした場合、このAttributeはデータ保存時にインデックスを作成する。
このインデックスは、データベース内の検索を高速化するために用いられる。
該当Attributeを用いて検索やソートを行う場合、索引付きにしておくことでかなりの高速化効果が期待できる。しかしながら、検索やソートに用いないのであれば、逆効果を招きかねないのでチェックすべきではない。DBに保存時インデックス作成しているので保存時間がかかります。

【Attribute Type】
- Integer 16:-32,768 to 32, 767
- Integer 32:-2,147,483,648 to 2,147,483,647
- Integer 64:-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

2012년 8월 20일 월요일

モダルビューアからキーボードを非表示にする方法


- (IBAction)close:(id)sender {
    [textField resignFirstResponder];
    @try
    {
        Class UIKeyboardImpl = NSClassFromString(@"UIKeyboardImpl");
        id activeInstance = [UIKeyboardImpl performSelector:@selector(activeInstance)];
        [activeInstance performSelector:@selector(dismissKeyboard)];
    }
    @catch (NSException *exception)
    {
        NSLog(@"%@", exception);
    }
}