本項目是《beginning iOS8 programming with swift》中的項目學習筆記==》所有筆記目錄html
------------------------------------------------------------------------------------------------------------------swift
1. 將Resturant控制器Embedded in一個導航控制器,設置標題爲Food Pin.
2. 拖一個視圖控制器到界面,界面上放一個UIImageView控件。新建一個DetailViewController的類繼承自UIViewController,設置爲控制器的類。
3. 從單元格拖一條線到新加的試圖控制器,選擇push,命名爲showResturantDetail。
4. 在DetailViewController中關聯圖片控件,並增長一個成員變量記錄圖片名稱:ide
class DetailViewController: UIViewController { @IBOutlet weak var imageView: UIImageView! var imageName:String! override func viewDidLoad() { super.viewDidLoad() imageView.image = UIImage(named: imageName) } }
5. 去掉ResturantTableViewController中的didSelectRow方法,修改界面Cell的AccessoryIndicator爲None,增長prepareForSegue方法:學習
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if segue.identifier == "showResturantDetail" { if let indexPath = tableView.indexPathForSelectedRow() { let detailController = segue.destinationViewController as DetailViewController detailController.imageName = restaurantImages[indexPath.row] } } }