2017-06-14 9 views
0

内Objective-Cのを使用してのViewControllerを起動するまず、私はそれはコルドバプロジェクト

を維持されているかのアプリの構造を説明しましょう私はここで二つのアプリケーション

まず、ネイティブのObjective-CベースのiOSアプリケーションを持っています完璧に動作し、ネイティブアプリケーションのタスクは、アプリケーションが起動されると、カメラを起動し、画像をキャプチャし、いくつかのOpenGL処理を行い、キャプチャされた画像を表示することです。

これのViewControllerクラスは&今のストーリーボード

を起動し実行している&をアプリを取得するいくつかのプロパティを持ってい

#import <UIKit/UIKit.h> 
#import "ViewController.h" 

int main(int argc, char * argv[]) { 
    @autoreleasepool { 
     return UIApplicationMain(argc, argv, nil, NSStringFromClass([ViewController class])); 
    } 
} 

下に示すように、これは私のmain.mファイル内のViewControllerクラスを呼び出すことによって行われます私はプラグインを作成し、すべてのネイティブファイルをプラグインに統合したので、プラグインを追加すると、ソースファイル、リソースファイル、資産、ストーリーボードなどを含むすべてのリソースが追加されます。

以下

我々はジャバスクリプト内のプラグインをトリガするとき、それは、プラグインの開始点であるネイティブクラスCustomPluginを呼ぶ、と同じ

のヘッダ&実装コードがCustomPlugin.h

#import <Cordova/CDV.h> 
#import "ViewController.h" 

@interface CustomPlugin : CDVPlugin 

- (void) pluginInitialize; 

- (void) process:(CDVInvokedUrlCommand*)command; 

@end 

#import "CustomPlugin.h" 
#import "ViewController.h" 


@interface CustomPlugin() 

@end 

@implementation CustomPlugin 

NSString *_routeChangedCallbackId; 
@synthesize viewc; 


- (void) pluginInitialize { 
    NSLog(@"CustomPlugin:pluginInitialize"); 

    _routeChangedCallbackId = nil; 
} 

- (void) process:(CDVInvokedUrlCommand*)command 
{ 
    CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"test"]; 
    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; 
} 

@end 

CustomPlugin.hこの実装は、現在だけで、発信者に応答サンプルメッセージを送り返す

私が達成したいのは、ネイティブで働いているようにViewController機能を起動/起動/初期化できることです。

私は長すぎる質問をお待ちしています。

答えて

0

以下の記事を参照してください、コルドバのプラグインからのViewControllerを起動する私の問題を解決できます

Plugin with UIViewController

0

pluginInitialize方法はCDVPluginResultとcommandDelegateメソッドの間に呼び出される必要があります。

に成功しました
- (void) process:(CDVInvokedUrlCommand*)command 
    { 
     CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"test"]; 

     [self pluginInitialize]; 

     [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; 
    } 

https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithObjects/WorkingwithObjects.html

関連する問題