0
私は選択されたUITableviewCell
学生セルの情報を、情報の各部分(名、姓など)についてUITextField
のビューコントローラにプッシュしようとしています。変更されましたが、辞書から各テキストフィールドにその情報をプッシュする方法を見つけることができません。私は不運でそれを再割り当てしようとしました。ここで辞書からUITextField(Swift)への情報のプッシュ
は私の辞書迅速ファイルの私のサンプル
class ClassRosterModel {
//Student Dictionary for Student infomation
var studentsRoster = [Dictionary<String, String>]()
init() {
studentsRoster.append(["firstName": "Alex" , "lastName" : "Kaz", "major" : "SE", "email" : "[email protected]", "currentTerm" : "Spring", "numberOfCredits" : "\(randomCredits[0])", "password" : "000000"])
}
そして、ここではセグエ
class ClassRosterTableViewController: UITableViewController {
//declaring studentsList dictionary
var studentsList = [Dictionary<String, String>]()
var selectedRowIndex = 0
//Assignment of studentsList and myStudentRoster
let myStudentRoster = ClassRosterModel()
studentsList = myStudentRoster.studentsRoster
//declaring cell with identifier from studentCell.
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("studentCell", forIndexPath: indexPath)
// Configuring the cell with student information
cell.textLabel?.text = "\(studentsList[indexPath.row]["lastName"]!), \(studentsList[indexPath.row]["firstName"]!) - \(studentsList[indexPath.row]["email"]!)"
cell.detailTextLabel?.text = "\(studentsList[indexPath.row]["currentTerm"]!) - \(studentsList[indexPath.row]["numberOfCredits"]!) credits"
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let dvc = segue.destinationViewController as! StudentInfoViewController
let selectedStudent = studentsList[selectedRowIndex]
dvc.studentRecord = selectedStudent
}
そして私と を選択する前に、すべてのセルを持っている私のクラスの一部であります 学生情報ページの最初のテキストフィールドを作成しました
class StudentInfoViewController: UIViewController {
@IBOutlet weak var FirstNameTextField: UITextField!
var studentRecord = Dictionary<String, String>()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}