ios - swift module extension prompt method not found
大家讲道理
大家讲道理 2017-07-03 11:43:07
0
1
1583

Follow the steps described on the official website

  1. Create a new SelfModule.m/.h file, import project-swift.h, and define and expose the jumpNextPage(params: String) method to the outside world

#import "SelfModule.h"
#import "Project-Swift.h"
#import "Project-Bridging-Header.h"

@implementation SelfModule
#pragma clang diagnostic push //关闭unknow selector的warrning
#pragma clang diagnostic ignored "-Wundeclared-selector"

@synthesize weexInstance;

    WX_EXPORT_METHOD(@selector(jumpNextPage))

#pragma clang diagnostic pop
@end
  1. Create a new SelfModule.swift file and extend the SelfModule method

public extension SelfModule{
    
    public func jumpNextPage(params : NSString){
        let controller = UIViewCtroller()
        weexInstance.viewController.navigationController?.pushViewController(controller, animated:true)
    }
}
  1. Register Module in AppDelegate,

WXSDKEngine.registerModule("self_module", with: NSClassFromString("SelfModule"))

Result prompt

method:jumpNextPage for module:self_module doesn't exist, maybe it has not been registered [;

There is no problem on Android, but an error is reported on iOS, please find out the reason

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(1)
迷茫

Have a look at the imported bridging file? It’s in Project-Bridging-Header.h

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template