まず、よくストリーボードでviewControllerからviewControllerをつなぐsegueをモーダルで画面遷移を定義していくが、AからBへいってBからAに戻る遷移をモーダルでつなぐ人がいたので、それはさすがに違うだろうと思うので実際確認してみた。
- (void)viewDidAppear:(BOOL)animated
[super viewDidAppear:animated];
2011-12-06 00:26:53.328 modaltest[25564:f803]
2011-12-06 00:26:56.094 modaltest[25564:f803]
2011-12-06 00:27:04.040 modaltest[25564:f803]
2011-12-06 00:27:05.722 modaltest[25564:f803]
2011-12-06 00:27:09.271 modaltest[25564:f803]
2011-12-06 00:27:11.272 modaltest[25564:f803]
当たり前だけど、違うメモリアドレスを返してくる。やはり、モダールはちゃんと
dismissは自分で実装しないといけないみたい。
メモリは同じなので、遷移のスタックがたまっていってるのかな。
資料を探して行き詰まっていたけど、なんだかんだでたよりになるのは
リストテンプレートを見ればsegueからデータを次のviewControllerに渡す方法も分かる。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
if ([[segue identifier] isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSManagedObject *selectedObject = [[self fetchedResultsController] objectAtIndexPath:indexPath];
[[segue destinationViewController] setDetailItem:selectedObject];
リストテンプレートにCoreDataをチェックして作れば、動的Propetyでの利用の仕方が分かる。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; return cell;