我想從UITableView Cell
,當點擊單元格,去在另一個ViewController
迅速。我有一個名爲MainMenu的viewController
,它是我的UITableView
,我正嘗試點擊一個單元格,然後轉到我的其他ViewController
。有人可以幫忙嗎?UITableView單元到一個新的ViewController
我的UITableView的代碼調用主菜單:
class MainMenu: UITableViewController {
// Set Tabs in Table View Controller
var tabs = [String]()
override func viewDidLoad() {
super.viewDidLoad()
// Name of Tabs
tabs = ["Scanner","QR-Codes","Cargo","Matrix","Xbox","PS4","Nintendo","Sega","Dreamcast","Xbox360","GameCube","Wii","Challenger","Mustang","Macbook","Logitech"]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tabs.count
}
// Set Tabs in View
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("scannerCell", forIndexPath: indexPath) as UITableViewCell
cell.textLabel!.text = tabs[indexPath.row]
print(tabs)
// return
return cell
}
}
這只是繪製屏幕的代碼。當你點擊一個單元格或移動到另一個viewController時,你無處可做。如果你問如何做到這一點......有(數百個)stackoverflow問題和數以千計的教程來展示如何做到這一點。在提出問題之前,請做一些調查並嘗試一下。 –
對不起剛纔需要幫助@SimonMcLoughlin –