2014-05-01から1ヶ月間の記事一覧
監視オブジェクトの追加 [self addObserver:self forKeyPath:@"frame" options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:NULL]; 監視オブジェクトの受信 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)objec…
self.view.autoresizingMask = UIViewAutoresizingNone;
#import "DDLog.h" #import "DDTTYLogger.h" #ifdef DEBUG static const int ddLogLevel = LOG_LEVEL_VERBOSE; #else static const int ddLogLevel = LOG_LEVEL_OFF; #endif
SDWebImage の downloadWithURL:options:progress:completed: を使う。 [[SDWebImageManager sharedManager] downloadWithURL:imageURL options:SDWebImageHighPriority progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheTy…
高さが固定じゃなく、セルの内容毎に高さが変わる場合がありますよね。そういう場合には Auto Layout で上下の Constraints を指定しつつ、systemLayoutSizeFittingSize: メソッドを使うと簡単に高さが取得出来ました(ちょっと処理が重い?)。 - (CGFloat)…
UITableView でも UIScrollView でも同じように設定できるっぽい。 scrollView.contentInset = UIEdgeInsetsMake(0.0, 0.0, 50.0f, 0); scrollView.scrollIndicatorInsets = UIEdgeInsetsMake(0.0, 0.0, 50.0f, 0); 参考:UIScrollViewに余白を設定する
こんなカテゴリを用意しておくと楽かも。 - (BOOL)lxx_empty { return ([[self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] length] == 0); }
そんなことってあると思います。でも普通に見ようとすると、 (lldb) p tableView.bounds error: unsupported expression with unknown type error: unsupported expression with unknown type error: 2 errors parsing expression となってしまって見れませ…
layoutSubviews はビューを addSubview したときやビューの frame を変更したとき(親ビューの layoutSubviews 経由、画面回転時など)に呼ばれる。大抵意識することなく必要な時に呼ばれるけど、任意のタイミングで呼びたいときには setNeedsLayout を呼ぶ…
[NSString stringWithFormat:@"%d", 10]; // int から NSString に [@10 stringValue]; // NSNumber から NSString に [@"hoge" intValue]; // NSString から int に
アイコンにバッジを表示する。 // int を指定する [UIApplication sharedApplication].applicationIconBadgeNumber = 10; タブにバッジを表示する。 // NSString を指定する self.navigationController.tabBarItem.badgeValue = [NSString stringWithFormat:…
- (void)viewDidLoad { [super viewDidLoad]; [self registerForKeyboardNotifications]; } // キーボードの表示/非表示の通知を受け取る - (void)registerForKeyboardNotifications { [[NSNotificationCenter defaultCenter] addObserver:self selector:@se…
例えば UIAlertView を利用する場合、 こんな感じで使える。便利〜。 #import "UIAlertView+BlocksKit.h" [UIAlertView bk_showAlertViewWithTitle:@"title" message:@"message" cancelButtonTitle:@"cancel" otherButtonTitles:@[@"ok"] handler:^(UIAlertV…
遷移元を viewController 、表示したモーダルを modalViewController とすると viewController.presentedViewController // modalViewController modalViewController.presentingViewController // viewController ( modalViewController を表示しているビュ…
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; ModalViewController *modalViewController = [storyboard instantiateViewControllerWithIdentifier:@"ModalViewController"]; [self presentViewController:modalViewC…