我增加了UITextField一个UIAlertController,这似乎为AlertView.在解雇之前UIAlertController,我想验证输入UITextField.基于验证,我想解雇UIAlertController或不解雇.但我不知道如何防止UIAlertController按下按钮时的解除动作.有没有人解决这个问题或任何想法从哪里开始?我去谷歌但没有运气:/谢谢!
任何人都可以告诉我如何验证UITextFields内部UIAlertController?
除非输入两个字段,否则我需要它来阻止用户单击"保存".
到目前为止,这是我的代码:
@IBAction func btnStart(sender: AnyObject) {
var alert = UIAlertController(title: "New user",
message: "Add a new user",
preferredStyle: .Alert)
let saveAction = UIAlertAction(title: "Save",
style: .Default) { (action: UIAlertAction!) -> Void in
self.textFieldName = alert.textFields![0] as UITextField
self.textFieldEmail = alert.textFields![1] as UITextField
self.saveUser(self.textFieldName.text, email: self.textFieldEmail.text)
self.tableView.reloadData()
}
saveAction.enabled = false
let cancelAction = UIAlertAction(title: "Cancel",
style: .Default) { (action: UIAlertAction!) -> Void in
}
alert.addTextFieldWithConfigurationHandler {
(textFieldName: UITextField!) in
textFieldName.placeholder = "Enter full name" …Run Code Online (Sandbox Code Playgroud) 我正在努力使用以下代码:
backgroundTimer = NSTimer.scheduledTimerWithTimeInterval(3, target: gvc, selector: #selector(GameViewController.addNext), userInfo: nil, repeats: true)
Run Code Online (Sandbox Code Playgroud)
我似乎无法让#selector工作.此代码的结果是:
Type 'GameViewController' has no member 'addNext'
Run Code Online (Sandbox Code Playgroud)
即使会员就在那里......这是完整的代码:
class GameViewController: GAITrackedViewController, AVAudioPlayerDelegate {
var sceneCanvas: SKSpriteNode?
override func viewDidLoad() {
skView.presentScene(WelcomeScene(size: view.bounds.size, gvc: self))
}
func createBackground(boundsSize: CGRect, gvc: GameViewController) -> SKSpriteNode {
addUILabels(gvc)
return sceneCanvas!
}
func addUILabels(gvc: GameViewController) {
backgroundTimer = NSTimer.scheduledTimerWithTimeInterval(3, target: gvc, selector: #selector(GameViewController.addNext), userInfo: nil, repeats: true)
}
public func addNext() {
let backgroundLabel = SKSpriteNode(imageNamed: "label1.png")
sceneCanvas!.addChild(backgroundLabel!)
backgroundLabel?.runAction(SKAction.moveByX(-screenSize.width , y: 0, duration: …Run Code Online (Sandbox Code Playgroud) 我使用的是UIAlertController提出了一个对话UITextField和一个UIAlertAction按钮标记为"好".如何将多个字符(例如5个字符)输入到UITextField?中,如何禁用该按钮?
看看我的下面的代码.我正在尝试使用uialertviewcontroller.Now添加文本字段当我的两个文本字段中没有输入时我需要禁用两个操作按钮.怎么做?
请提出一些可能的解决方案.谢谢!!
ios ×4
swift ×3
objective-c ×2
uitextfield ×2
nstimer ×1
selector ×1
sprite-kit ×1
uialertview ×1