所以我目前正在使用一个具有 XIB 文件的 SDK,并且我已经将一个按钮连接到它的 View Controller ,如下面的代码所示。我已经在 pod 库本身中完成了此操作
- (IBAction)testButton:(UIButton *)sender {
NSLog(@"test");
}
然后我将我将此方法放入我的 swift 文件中的类子类化。但是,我无法从 swift 文件本身访问此按钮。如何从我的 swift 文件本身覆盖此按钮的功能?
class MyLoginViewController: BLoginViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
//I am unable to override the button in this view controller
最佳答案
在您的 BLoginViewController.h 中添加这一行
- (IBAction)testButton:(UIButton *)sender;
现在您可以像这样在 MyLoginViewController 中覆盖此方法
override func test(_ sender: UIButton!) {
}
关于ios - 在 objective-c 文件中有一个按钮(来自 pod)并从 swift 中继承它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48180461/