奇怪的快速内插错误:找不到成员'convertFromStringInterpolationSegment' [英] Weird swift interpolation error: Could not find member 'convertFromStringInterpolationSegment'

查看:85
本文介绍了奇怪的快速内插错误:找不到成员'convertFromStringInterpolationSegment'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在以下代码中使用swift插值时,出现一个奇怪的错误:

I get a weird error when I try to use swift's interpolation in the following code:

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        var alert = UIAlertController(title: "Clicked!",
                                      message:"You clicked row # \(indexPath.row)",
                                      preferredStyle: UIAlertViewStyle.Default);
    }

我还没有完成警报视图,但是我不认为这是导致错误的原因.它发生在message参数上.

I haven't finished the alert view yet, but I don't think thats the cause of the error. Its happening at the message parameter.

感谢您的提前帮助!

推荐答案

您在此处选择了错误的enum值.此代码存在问题:

You chose the wrong enum value there. Issue is with this code:

UIAlertViewStyle.Default

将其更改为:

UIAlertControllerStyle.Alert

UIAlertViewStyle.Default用于指定UIAlertviewUIActionSheet的按钮样式.

UIAlertViewStyle.Default is used for specifying the button styles of UIAlertview and UIActionSheet.

参考

UIAlertControllerStyle

指示要显示的警报类型的常量.

UIAlertControllerStyle

Constants indicating the type of alert to display.

ActionSheet 在提供它的视图控制器的上下文中显示的动作表. 使用操作表向用户展示如何进行给定任务的一组替代方法.您也可以使用此样式 提示用户确认潜在的危险动作. 在iOS 8.0和更高版本中可用.

ActionSheet An action sheet displayed in the context of the view controller that presented it. Use an action sheet to present the user with a set of alternatives for how to proceed with a given task. You can also use this style to prompt the user to confirm a potentially dangerous action. Available in iOS 8.0 and later.

警告

以模态方式显示该应用的警报.

An alert displayed modally for the app.

在iOS 8.0和更高版本中可用.

Available in iOS 8.0 and later.

参考

UIAlertActionStyle

应用于警报中的操作按钮的样式.声明常量

UIAlertActionStyle

Styles to apply to action buttons in an alert. Declaration Constants

默认 将默认样式应用于操作按钮. 在iOS 8.0和更高版本中可用.

Default Apply the default style to the action’s button. Available in iOS 8.0 and later.

取消 应用一种样式,该样式指示操作将取消操作并使所有内容保持不变. 在iOS 8.0和更高版本中可用.

Cancel Apply a style that indicates the action cancels the operation and leaves things unchanged. Available in iOS 8.0 and later.

破坏性 应用指示操作可能更改或删除数据的样式. 在iOS 8.0和更高版本中可用.

Destructive Apply a style that indicates the action might change or delete data. Available in iOS 8.0 and later.

这篇关于奇怪的快速内插错误:找不到成员'convertFromStringInterpolationSegment'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆