AlertView에서 데이터를 수집하고 싶습니다. AlertController의 기능AlertView with textbox, 입력 된 텍스트 상자에서 데이터를 수집하는 방법
@IBAction func showAlertTapped(sender: AnyObject) {
//Create the AlertController
let actionSheetController: UIAlertController = UIAlertController(title: "Add User", message: "Enter username", preferredStyle: .Alert)
//Create and add the Cancel action
let cancelAction: UIAlertAction = UIAlertAction(title: "Cancel", style: .Cancel) { action -> Void in
//Do some stuff
}
actionSheetController.addAction(cancelAction)
//Create and an option action
let saveAction: UIAlertAction = UIAlertAction(title: "Save", style: .Default) { action -> Void in
//Do some other stuff
}
actionSheetController.addAction(saveAction)
//Add a text field
actionSheetController.addTextFieldWithConfigurationHandler { textField -> Void in
//TextField configuration
textField.textColor = UIColor.blueColor()
}
//Present the AlertController
self.presentViewController(actionSheetController, animated: true, completion: nil)
}
임 모르고, 그래서 예에 entred 텍스트를 가지고 어디 몰라 : 내가 www가에서 발견 한 것은 이것이다 간단한 변수? UIAlertController가 textFields 속성이 같은
참고가 유형을 정의하고 있기 때문에 또한'... 그것은'하자 saveAction = UIAlertAction (즉 추론 할 수 – Jawwad
을 두지 않을보다 간결한 코드를 만들 수 있습니다 '.ActionSheet' 스타일이 아닌'.Alert' 스타일을 사용하고 있습니다. 여러분의 변수의 이름을'actionSheetController'가 아닌 다른 것으로 바꿀 수도 있습니다. – Jawwad