我正在尝试集成库 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 分钟。
有好心人能帮我解决这个问题吗?请 :)