The Pragmatic Ball boy

iOSを中心にやってる万年球拾いの老害エンジニアメモ

iOSプログラミング忘備録その2

クラスの比較
[self isKindOfClass:[object class]]


toString的なもの
- (NSString*)description

NSDictionaryの中を順番に取り出す方法
for (NSString* key in xyz) {
id value = [xyz objectForKey:key];
// do stuff
}

キーボードを閉じる
[searchBar resignFirstResponder]

Enterでキーボードを閉じる

returnKeyTypeを"UIReturnKeyDone"にし、

memoField.returnKeyType = UIReturnKeyDone;

UITextFieldDelegateプロトコルを継承して、delegate登録。


memoField.delegate = self;


- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [memoField resignFirstResponder];
    return YES;
}



StoryBoardでの画面遷移時に遷移先のViewControllerに何か渡したい場合
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

segue.destinationViewController を使う。

UIButtonへの画像の貼り付け
プロパティにセットするのでは反映されない。
    buttonA.imageView.image = image;

setImageを使う
    [buttonA setImage:image forState:UIControlStateNormal];

デフォルトの色を変える
 [[NavigationBar appearance] setTintColor:[UIColor redColor];