저는 신속하게 사용하기가 매우 쉽지만 대부분을 따라 할 수있었습니다. 그러나 코드 자체가 코드를 식별 할 수 없다는 오류가 있습니다 (오류가 발생하지 않음). 다음 페이지로 이동하려면 테이블보기에서 행을 클릭하려고하지만 코드를 didselectrow 메서드를 인식하는 생각하지 않습니다. 어쩌면 당신 중 하나가 더 많은 경험이있는 사람이 나를 도울 수 있습니다. 여기 Swift 3에서 "didSelectRowAt indexPath"문제가 있습니다.
코드입니다 :import UIKit
import Foundation
class OnePercentersViewController: UIViewController, UITableViewDataSource
{
var copiedExecutiveArray : [String] = NSArray() as! [String]
var identities : [String] = NSArray() as! [String]
override func viewDidLoad()
{
super.viewDidLoad()
let copyExecutiveNames : ExecutiveArray = ExecutiveArray()
copiedExecutiveArray = copyExecutiveNames.executiveNames
identities = copyExecutiveNames.executiveNames
}
//how many sections in table
func numberOfSections(in tableView: UITableView) -> Int
{
return 1
}
//returns int (how many rows)
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return copiedExecutiveArray.count
}
//contents of each cell
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell")//UITableViewCell()
let personName = copiedExecutiveArray[indexPath.row]
cell?.textLabel?.text = personName
return cell!
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
let execName = identities[indexPath.row]
let viewController = storyboard?.instantiateViewController(withIdentifier: execName)
self.navigationController?.pushViewController(viewController!, animated: true)
print("button clicked")
tableView.deselectRow(at: indexPath as IndexPath, animated: true)
}
}
하지'관련 그러나 VAR의 정체성 : 같은 [문자열] = NSArray를()! [String]'은 끔찍합니다. 간단히'var identities = [String]()'라고 쓰십시오. – vadian