delegate.m didFinishLaunchingWithOptions
GeneratedPluginRegistrant.register(with: self)
let registrar = self.registrar(forPlugin: "FlutterIosPay")!
let factory = MyPlatformViewFactory(messenger: registrar.messenger())
registrar.register(factory, withId: "FlutterIosPay/custom_platform_view")
Flutter2OCBridge.register(with: registrar);
MyPlatformViewFactory
import UIKit
import Flutter
class MyPlatformViewFactory: NSObject, FlutterPlatformViewFactory {
var messenger: FlutterBinaryMessenger
init(messenger:FlutterBinaryMessenger) {
self.messenger = messenger
super.init()
}
func create(withFrame frame: CGRect, viewIdentifier viewId: Int64, arguments args: Any?) -> FlutterPlatformView {
return MyPlatformView(frame: frame, viewIdentifier: viewId, arguments: args, binaryMessenger: self.messenger)
}
func createArgsCodec() -> FlutterMessageCodec & NSObjectProtocol {
return FlutterStandardMessageCodec.sharedInstance()
}
}
MyPlatformView
import Flutter
import UIKit
class MyPlatformView: NSObject, FlutterPlatformView {
var _view: UIView
init(frame: CGRect, viewIdentifier: Int64, arguments: Any?, binaryMessenger: FlutterBinaryMessenger) {
print("---------------->webview frame:\(frame) <-------------");
_view = UIView(frame: frame)
if arguments is NSDictionary {
let dict = arguments as! NSDictionary
if(dict["page"] as! String == "portalWebView"){
let tView = PortalWebView(frame: frame)
tView.transferDataDic = arguments as! [AnyHashable : Any];
_view = tView;
}
}else{
}
}
func view() -> UIView {
return _view
}
}