这张图应该说够了:
我一直在网上寻找答案,似乎没有其他人有这个问题。我正在使用Xcode 7 Beta 3和Swift 2.我无法弄清楚出了什么问题。
提前致谢
编辑:
以下是代码:
func input(text:String) -> String {
Say(text)
let alert:UIAlertController = UIAlertController(title: "Goog", message: text, preferredStyle: UIAlertControllerStyle.Alert)
[alert .addTextFieldWithConfigurationHandler({ (textfield: UITextField!) -> Void in
})]
var returnValue:String = ""
let confirmAction = UIAlertAction(
title: "OK", style: UIAlertActionStyle.Default) {(action) in
returnValue = (alert.textFields[0] as UITextField).text!
return
}
return returnValue
}
答案 0 :(得分:-1)
您希望将Swift枚举用于此类操作样式:
let alertAction2 = UIAlertAction(title: "My Alert", style: .Default)
{(action:UIAlertAction) -> Void in
// do something with action
return
}
或者更简洁:
let alertAction2 = UIAlertAction(title: "My Alert", style: .Default)
{action in
// do something with action
}
答案 1 :(得分:-1)
UIAlertController *altSuccess = [UIAlertController alertControllerWithTitle:@"Success" message:@"Login Successfully" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okSuccess = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
NSLog(@"%@",[dict objectForKey:@"email"]);
NSLog(@"%@",[dict objectForKey:@"password"]);
[altSuccess dismissViewControllerAnimated:YES completion:nil];
}];
[altSuccess addAction:okSuccess];
[self presentViewController:altSuccess animated:YES completion:nil];
它的工作正常......