iOSアプリ開発のメモ置き場

ささたつがiOSアプリ開発で知ったObjective-Cのtipsなどを書いていく所存

Storyboard で作成した ViewController を呼び出す

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ModalViewController *modalViewController = [storyboard instantiateViewControllerWithIdentifier:@"ModalViewController"];
[self presentViewController:modalViewController animated:YES completion:nil];


そうすると ModalViewController の initWithCoder: が呼ばれるわけか。フムフム。

テーブルビューをタブバーの下に潜り込ませる方法

translucent を設定するとタブバーを半透明にすることが出来、タブバーの下に tableView が潜りこむようになります。iOS7からはこれがデフォルトの挙動。

self.tabBarController.tabBar.alpha = 0.5;
self.tabBarController.tabBar.translucent = NO;
self.tabBarController.tabBar.backgroundColor = [UIColor greenColor];


さらに、タブバーが不透明であっても extendedLayoutIncludesOpaqueBars が YES であれば同様の挙動になる。

self.tabBarController.tabBar.translucent = YES;
tableViewController.extendedLayoutIncludesOpaqueBars = NO;

責任範囲を明確にして粗結合なアプリにしたい

責任範囲を明確にして粗結合なアプリにしたいと思っている今日この頃。

ViewController で何でもやらせたいくない。View では表示だけをさせたい。ロジックは Model にやらせたい。etc...


いろいろありますが、こういう問題を解決するにはこの辺をうまく使えば良いんでしょうか。まだまだわからないことだらけ><

  • delegate (王道)
  • block記法 / BlocksKit (慣れてくると楽かも)
  • Notification (処理がごちゃごちゃしそう…)

ある要素の隣に別の要素を置きたいときには CGRectOffset が便利!

詳しくはこちらを参照。ある要素を基準として、オフセットを指定するだけ〜


座標をオフセット指定で操作できるCGRectOffset - hachinoBlog
http://hachinobu.hateblo.jp/entry/2014/02/09/223213