如何在swift中调用initWith ... [英] How to call initWith... in swift

查看:86
本文介绍了如何在swift中调用initWith ...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Objective-c类(RDAlertView),它创建一个Alert(UOSlertView for ios< 8和UIAlertController for ios> = 8)

I have a an objective-c class (RDAlertView) which create an Alert (UIAlertView for ios < 8 and UIAlertController for ios >=8 )

以下是Objective-C中的代码:

Here is the code in Objective-C:

RDAlertView* alert = [[RDAlertView alloc] initWithTitle:@"Notification" 
                                                message:@"message" 
                                             completion:completion:^(NSInteger buttonIndex, NSInteger cancelButtonIndex, NSArray *textflieds) { } 
                                      cancelButtonTitle:@"Ok" 
                                      otherButtonTitles:nil];

[alert show];

我的问题是:如何在Swift中调用它而不改变我的课程(如果可能)?

My question is: How to call this in Swift without any change in my class (if possible)?

以下是示例项目的链接: https ://bitbucket.org/ejanowski/rdalertview-issue

Here is a link for the sample project : https://bitbucket.org/ejanowski/rdalertview-issue

推荐答案

我认为这就是你所需要的:

I think this is what you need:

var alert = RDAlertView(title: "Notification", message: "message", completion: nil, cancelButtonTitle: "OK", otherButtonTitles: nil)
alert.show()

希望它会有所帮助。

这篇关于如何在swift中调用initWith ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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