0

这张照片应该说够了: 在此处输入图像描述

我一直在网上寻找答案,但似乎没有其他人有这个问题。我正在使用 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
}
4

2 回答 2

-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];

它的工作正常...

于 2016-06-16T04:27:11.423 回答
-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
        }
于 2015-07-20T18:49:17.183 回答