&tag(Storyboard);
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc:UIViewController = storyboard.instantiateViewControllerWithIdentifier("WebViewController")
let webViewController = vc as! WebViewController
webViewController.initialUrl = urlString
self.navigationController!.presentViewController(vc, animated: true, completion: nil)
※UITableViewControllerを使わないと、Static Cellsが使えない。
※ちなみにios - StoryboardのNavigation Barの存在理由 - スタック・オーバーフローによると、NavigationBarを個別に追加する必要はほとんどないらしい。
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
override func setEditing(editing: Bool, animated: Bool) {
super.setEditing(editing, animated: animated);
self.navigationController?.setToolbarHidden(editing, animated:true)
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if tableView.isEditing {
let shelf = fetchedResultsController.object(at: indexPath)
performSegue(withIdentifier: "editShelf", sender: shelf)
} else {
let shelf = fetchedResultsController.object(at: indexPath)
performSegue(withIdentifier: "listBook", sender: shelf)
}
}
@IBAction func unwindToTop(segue: UIStoryboardSegue) {
}
self.performSegue(withIdentifier: "back", sender: nil)
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return rows.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "myCell", for: indexPath)
cell.textLabel!.text = rows[indexPath.row]
return cell;
}