facebook twitter hatena line email

Ios/swift/TableView/画面遷移

提供: 初心者エンジニアの簡易メモ
2016年7月5日 (火) 18:41時点におけるAdmin (トーク | 投稿記録)による版

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索

TableViewで表示されたCellをクリックした後に画面遷移させる方法

Navigationを使った場合のサンプル

   // Cell が選択された場合
   func tableView(table: UITableView, didSelectRowAtIndexPath indexPath:NSIndexPath) {
       let id: String! = self._imgs[indexPath.row].id
       if id != nil {
           let appDelegate:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
           let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
           let detailViewController = storyboard.instantiateViewControllerWithIdentifier("DetailViewControllerId") as! DetailViewController
           detailViewController.id = id
           appDelegate.navigationController?.pushViewController(detailViewController, animated: false)
       }
   }