显示来自 cordova 插件的原生 IOS 按钮

Show native IOS button from cordova plugin

我正在尝试编写一个 cordova 插件,它将向 cordova 视图添加一个 iOS 本机按钮(我认为是 UIButton?)。我在这方面是一个完全的业余爱好者,所以我会很感激一些帮助。这是我的插件代码:

#include "CordovaButton.h"

@implementation CordovaButton

- (void)pluginInitialize
{

}

- (void)getButton:(CDVInvokedUrlCommand *)command
{

    // define error variable
    NSString *error = nil;

    // create array to hold args
    NSArray* args = command.arguments;

    // create variable to hold response
    CDVPluginResult* pluginResult;

    // map command inputs
    NSString* callbackUrl = [args objectAtIndex:0];
    NSString* useCaseId = [args objectAtIndex:1];
    NSString* clientSdkId = [args objectAtIndex:2];
    NSString* scenarioId = [args objectAtIndex:3];

    if ([callbackUrl length] == 0) {
        error = @"missing callbackUrl";
    }

    if ([useCaseId length] == 0) {
        error = @"missing useCaseId";
    }

    if ([clientSdkId length] == 0) {
        error = @"missing clientSdkId";
    }

    if ([scenarioId length] == 0) {
        error = @"missing clientSdkId";
    }

    if ([error length] > 0) {
        pluginResult = [
            CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Missing an input"
        ];
    } else {
        pluginResult = [
            CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"it works"
        ];
    }
        
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 230, 48)];
    [button setTitle:@"my button" forState:UIControlStateNormal];
    
    [self.viewController.view addSubview:button];
}

@end

正在从 javascript 端调用此 getButton 方法,我希望本机按钮出现在屏幕上,但没有任何反应。 xcode 中的调试控制台只显示 ERROR: {} 这并没有多大帮助。出了什么问题?

我需要在顶部添加 @synthesize webView