0

我正在尝试集成库 BWWalkthrough (https://github.com/ariok/BWWalkthrough)。我能够成功地完成演练。我正在尝试在演练视图顶部添加登录/注册按钮,如下所示。这就是我面临的问题。

参考下图: 在此处输入图像描述

登录和“非会员”按钮应该分别启动登录和注册视图控制器。由于这 2 个按钮是在 BWWalkthroughViewController 中制作的,因此我尝试在所述控制器中添加 IBAction 并得到错误"Type 'BWalkthroughViewController' does not conform to the protocol 'LoginViewController'"。我到处搜索,但无法破解这个难题。

带有相关代码片段的 Codepen 在这里:http ://codepen.io/anon/pen/aONBVP?editors=001

//RegisterViewController
// Defined the delegate
import UIKit
import Parse

@objc protocol RegisterViewControllerDelegate {

}

class RegisterViewController: UIViewController, UITextFieldDelegate {

var delegate: RegisterViewControllerDelegate?

// BWWalkthroughViewController
// the troubled code

@IBAction func loginButtonTapped() {
}

@IBAction func registerButtonTapped() {
    println("registerButtontapped")

let stb = UIStoryboard(name: "Main", bundle: nil)
let register = stb.instantiateViewControllerWithIdentifier("register") as     RegisterViewController

register.delegate = self //the buggy line
// error is: Type 'BWWalkthroughViewController' does not conform to protocol 'RegisterViewControllerDelegate'
self.presentViewController(register, animated: true, completion: nil)

}

我已按照 youtube 教程:https ://www.youtube.com/watch?v= O2mbveNs-0k 集成 BWWalkthrough。视频的相关部分大约为 11 分钟和 15 分钟。

有好心人能帮我解决这个问题吗?请 :)

4

1 回答 1

0

出色的 Simon Archer(创建了 youtube 指南的http://www.simonarcher.me/blog/wp/)在 youtube 上回答了我的疑问,我在这里分享:

“嗨,Talvinder,感谢您花时间观看视频。不幸的是,您遇到的问题是 Swift 1.2 版(以及 iOS 8.3)出现的问题。我将不得不更新视频,但 BWWalkthrough 的作者库(0.5 版)已对他的演示项目进行了更新更改,同时您可以比较他在该段中的代码,看看应该如何使用 Swift 1.2 处理它。再次感谢,我希望这会有所帮助!”

我注释掉了这login.delegate = self条线,问题就解决了。

于 2015-05-14T09:03:54.000 回答