3
iOS 용 phoneGap 플러그인을 만들고 있는데, NativeCode를 사용하여 서명을 그리고 JavaScript에 콜백 값을 전달합니다.JavaScript 양식에 콜백 값을 전달하는 방법 iOS 용 고유 코드?
natice 코드를 사용하여 서명을 성공적으로 그릴 수 있지만 저장된 서명의 반환 값을 JavaScript로 전달할 수는 없습니다. 내가 서명을 그리는 UIViewContoller 클래스를 호출하고, 저장 버튼을 나는 자바 스크립트에 반환 값을 전달하려는 "인쇄"기능에서
var MyPlugin = {
nativeFunction: function(types, success, fail) {
return Cordova.exec(success, fail, "MyPlugin", "print", types);
}
};
을 따를
자바 스크립트 코드입니다. SAVE 버튼을
코드 나 오류 또는 예외를 받고 있지 않다
// The first argument in the arguments parameter is the callbackID.
// We use this to send data back to the successCallback or failureCallback
// through PluginResult
self.callbackID = [arguments pop];
// Get the string that javascript sent us
NSString *stringObtainedFromJavascript = [arguments objectAtIndex:0];
// Create the Message that we wish to send to javascript
NSMutableString *stringToReturn = [NSMutableString stringWithString: @"StringReceived:"];
// Append the received string to the string we plan to send out
[stringToReturn appendString: stringObtainedFromJavascript];
// Create Plugin Result
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsString: [stringToReturn stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
// Checking if the string received is HelloWorld or not
if ([stringObtainedFromJavascript isEqualToString:@"SAVED"] == YES)
{
// Call the javascript success function
[self writeJavascript: [pluginResult toSuccessCallbackString:self.callbackID]];
}else
{
// Call the javascript error function
[self writeJavascript: [pluginResult toErrorCallbackString:self.callbackID]];
}
클릭합니다.
누구든지 나를 도와주세요. 어떤 suggetion을 주시면 감사하겠습니다.
미리 감사드립니다.