7
7

More than 5 years have passed since last update.

Storyboard と UITableViewDelegate

Posted at

あれやこれやにより Storyboard を本格的に触るのはこれが初めてで、以下は UITableViewController と併用した際のメモになります。

ナビゲーションのプッシュ遷移時に呼び出されるメソッドの順番。

  1. - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
  2. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
  3. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  4. 遷移先 -(void)viewWillAppear:(BOOL)animated

prepareForSegue:sender: の方が tableView:didSelectRowAtIndexPath: よりも早く呼ばれる。will の方ならそれよりも先に呼ばれる。セル選択・遷移時に一番最初に何かやりたければ will で。

prepareForSegue:sender: でも tableView.indexPathForSelectedRow で NSIndexPath がとれるので、遷移時であればこのやり方でも良いのかもしれない。

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7