我有一個Viewcontroller,它有一個View外部它(在這3個符號(viewcontroller,first responder,exit)之間),當我點擊一個按鈕時,它顯示了我的View,然後我爲它創建了一個類文件,並且此視圖中的文本字段數據必須返回到ViewController。 我該怎麼做?我只通過segues知道方法。 tksViewController中UIview之間傳遞數據
-1
A
回答
0
0
告訴你的視圖控制器它符合UITextFieldDelegate協議。
class MyViewController : UIViewController <UITextFieldDelegate>
確保您的UITextField委託屬性被連接到視圖控制器。您可以通過IB或代碼來完成此操作。
@IBOutlet weak var myTextField: UITextField! //... later on... myTextField.delegate = self
從您的視圖控制器中的引用實現任何UITextFieldDelegate方法。例如:
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { print("text value is: \(textField.text)") }
相關問題
- 1. ObjectClass和ViewController之間傳遞數據
- 2. 在ViewController之間傳遞地圖數據
- 3. 在ViewController和TabBarController之間傳遞數據
- 4. 在uiview之間傳遞數據
- 5. 如何從自定義UIView中的ViewController傳遞數據
- 6. 在兩個ViewController之間傳遞數據時出錯
- 7. 使用NSUserDefaults在ViewController和TableVC之間傳遞數據(Swift)
- 8. 如何使用閉包在兩個ViewController之間傳遞數據
- 9. 如何在PageViewController和ViewController之間傳遞數據?
- 10. 獲取空值(在ViewController之間傳遞數據)
- 11. 無法在ViewController和子類之間傳遞數據
- 12. 在Segmentation之間傳遞ViewController數據的最佳方式
- 13. 在ViewController和TabBar子項之間傳遞數據
- 14. 在ViewController之間傳遞布爾值
- 15. 在ViewController和View之間傳遞句柄
- 16. 從ViewController B傳遞數據到ViewController A
- 17. 傳遞數據之間
- 18. 說明想要:UIViewController和UIView之間傳遞數據的概念
- 19. segue並將數據從viewcontroller傳遞到viewcontroller到另一個viewcontroller
- 20. 在函數之間傳遞元數據
- 21. 將Pop-over ViewController UITextfield中的數據傳遞迴Master ViewController
- 22. Swift:從ViewController中的tableView傳遞數據到另一個ViewController
- 23. 從ViewController傳遞數據到AppDelegate
- 24. 將數據傳遞給ViewController問題
- 25. 從viewcontroller反向傳遞數據到uitableviewcell
- 26. 將數據傳遞給特定的ViewController
- 27. 將Firebase數據從TableViewCell傳遞到ViewController
- 28. 從2個Tableviews傳遞數據到ViewController
- 29. 在兩個TableView之間傳遞數據
- 30. 在表單之間傳遞數據
[UITextFieldDelegate](https://developer.apple.com/documentation/uikit/uitextfielddelegate) – Frankie
對不起,我新在迅速,我需要一個例子。我該怎麼做:重寫func prepare(for segue:UIStoryboardSegue,sender:Any?){ if segue.identifier == segueAddQuoteViewController { if let destinationViewController = segue.destination as? AddQuoteViewController {// 配置視圖控制器 destinationViewController.managedObjectContext = persistentContainer.viewContext }} } 私人讓segueAddQuoteViewController = 「SegueAddQuoteViewController」 ...........我所需要的? –
@tiago .. - 不要在評論中張貼代碼。請[編輯](https://stackoverflow.com/posts/44935196/edit)您的問題與所有相關的細節。 – DonMag